Search in sources :

Example 1 with UIServer

use of org.deeplearning4j.ui.api.UIServer in project deeplearning4j by deeplearning4j.

the class FlowIterationListener method iterationDone.

/**
     * Event listener for each iteration
     *
     * @param model     the model iterating
     * @param iteration the iteration
     */
@Override
public synchronized void iterationDone(Model model, int iteration) {
    if (iterationCount.incrementAndGet() % frequency == 0) {
        currTime = System.currentTimeMillis();
        if (firstIteration) {
            // On first pass we just build list of layers. However, for MultiLayerNetwork first pass is the last pass, since we know connections in advance
            ModelInfo info = buildModelInfo(model);
            // send ModelInfo to stats storage
            Persistable staticInfo = new FlowStaticPersistable(sessionID, workerID, System.currentTimeMillis(), info);
            ssr.putStaticInfo(staticInfo);
        }
        // update modelState
        buildModelState(model);
        Persistable updateInfo = new FlowUpdatePersistable(sessionID, workerID, System.currentTimeMillis(), modelState);
        ssr.putUpdate(updateInfo);
        if (firstIteration && openBrowser) {
            UIServer uiServer = UIServer.getInstance();
            String path = "http://localhost:" + uiServer.getPort() + "/flow?sid=" + sessionID;
            try {
                UiUtils.tryOpenBrowser(path, log);
            } catch (Exception e) {
            }
            firstIteration = false;
        }
    }
    lastTime = System.currentTimeMillis();
}
Also used : FlowStaticPersistable(org.deeplearning4j.ui.flow.data.FlowStaticPersistable) FlowUpdatePersistable(org.deeplearning4j.ui.flow.data.FlowUpdatePersistable) Persistable(org.deeplearning4j.api.storage.Persistable) FlowStaticPersistable(org.deeplearning4j.ui.flow.data.FlowStaticPersistable) FlowUpdatePersistable(org.deeplearning4j.ui.flow.data.FlowUpdatePersistable) UIServer(org.deeplearning4j.ui.api.UIServer)

Example 2 with UIServer

use of org.deeplearning4j.ui.api.UIServer in project deeplearning4j by deeplearning4j.

the class TestPlayUI method testUIMultipleSessions.

@Test
@Ignore
public void testUIMultipleSessions() throws Exception {
    for (int session = 0; session < 3; session++) {
        StatsStorage ss = new InMemoryStatsStorage();
        UIServer uiServer = UIServer.getInstance();
        uiServer.attach(ss);
        MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT).iterations(1).list().layer(0, new DenseLayer.Builder().activation(Activation.TANH).nIn(4).nOut(4).build()).layer(1, new OutputLayer.Builder().lossFunction(LossFunctions.LossFunction.MCXENT).activation(Activation.SOFTMAX).nIn(4).nOut(3).build()).pretrain(false).backprop(true).build();
        MultiLayerNetwork net = new MultiLayerNetwork(conf);
        net.init();
        net.setListeners(new StatsListener(ss), new ScoreIterationListener(1));
        DataSetIterator iter = new IrisDataSetIterator(150, 150);
        for (int i = 0; i < 20; i++) {
            net.fit(iter);
            Thread.sleep(100);
        }
    }
    Thread.sleep(1000000);
}
Also used : OutputLayer(org.deeplearning4j.nn.conf.layers.OutputLayer) InMemoryStatsStorage(org.deeplearning4j.ui.storage.InMemoryStatsStorage) StatsStorage(org.deeplearning4j.api.storage.StatsStorage) IrisDataSetIterator(org.deeplearning4j.datasets.iterator.impl.IrisDataSetIterator) UIServer(org.deeplearning4j.ui.api.UIServer) StatsListener(org.deeplearning4j.ui.stats.StatsListener) InMemoryStatsStorage(org.deeplearning4j.ui.storage.InMemoryStatsStorage) MultiLayerConfiguration(org.deeplearning4j.nn.conf.MultiLayerConfiguration) DenseLayer(org.deeplearning4j.nn.conf.layers.DenseLayer) MultiLayerNetwork(org.deeplearning4j.nn.multilayer.MultiLayerNetwork) ScoreIterationListener(org.deeplearning4j.optimize.listeners.ScoreIterationListener) IrisDataSetIterator(org.deeplearning4j.datasets.iterator.impl.IrisDataSetIterator) DataSetIterator(org.nd4j.linalg.dataset.api.iterator.DataSetIterator) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 3 with UIServer

use of org.deeplearning4j.ui.api.UIServer in project deeplearning4j by deeplearning4j.

the class TestPlayUI method testUI_RBM.

@Test
@Ignore
public void testUI_RBM() throws Exception {
    //RBM - for unsupervised layerwise pretraining
    StatsStorage ss = new InMemoryStatsStorage();
    UIServer uiServer = UIServer.getInstance();
    uiServer.attach(ss);
    MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT).iterations(1).learningRate(1e-5).list().layer(0, new RBM.Builder().nIn(4).nOut(3).build()).layer(1, new RBM.Builder().nIn(3).nOut(3).build()).layer(2, new OutputLayer.Builder().nIn(3).nOut(3).build()).pretrain(true).backprop(true).build();
    MultiLayerNetwork net = new MultiLayerNetwork(conf);
    net.init();
    net.setListeners(new StatsListener(ss), new ScoreIterationListener(1));
    DataSetIterator iter = new IrisDataSetIterator(150, 150);
    for (int i = 0; i < 50; i++) {
        net.fit(iter);
        Thread.sleep(100);
    }
    Thread.sleep(100000);
}
Also used : OutputLayer(org.deeplearning4j.nn.conf.layers.OutputLayer) InMemoryStatsStorage(org.deeplearning4j.ui.storage.InMemoryStatsStorage) StatsStorage(org.deeplearning4j.api.storage.StatsStorage) IrisDataSetIterator(org.deeplearning4j.datasets.iterator.impl.IrisDataSetIterator) UIServer(org.deeplearning4j.ui.api.UIServer) StatsListener(org.deeplearning4j.ui.stats.StatsListener) InMemoryStatsStorage(org.deeplearning4j.ui.storage.InMemoryStatsStorage) MultiLayerConfiguration(org.deeplearning4j.nn.conf.MultiLayerConfiguration) RBM(org.deeplearning4j.nn.conf.layers.RBM) MultiLayerNetwork(org.deeplearning4j.nn.multilayer.MultiLayerNetwork) ScoreIterationListener(org.deeplearning4j.optimize.listeners.ScoreIterationListener) IrisDataSetIterator(org.deeplearning4j.datasets.iterator.impl.IrisDataSetIterator) DataSetIterator(org.nd4j.linalg.dataset.api.iterator.DataSetIterator) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 4 with UIServer

use of org.deeplearning4j.ui.api.UIServer in project deeplearning4j by deeplearning4j.

the class TestRemoteReceiver method testRemoteBasic.

@Test
@Ignore
public void testRemoteBasic() throws Exception {
    List<Persistable> updates = new ArrayList<>();
    List<Persistable> staticInfo = new ArrayList<>();
    List<StorageMetaData> metaData = new ArrayList<>();
    CollectionStatsStorageRouter collectionRouter = new CollectionStatsStorageRouter(metaData, staticInfo, updates);
    UIServer s = UIServer.getInstance();
    s.enableRemoteListener(collectionRouter, false);
    RemoteUIStatsStorageRouter remoteRouter = new RemoteUIStatsStorageRouter("http://localhost:9000");
    SbeStatsReport update1 = new SbeStatsReport();
    update1.setDeviceCurrentBytes(new long[] { 1, 2 });
    update1.reportIterationCount(10);
    update1.reportIDs("sid", "tid", "wid", 123456);
    update1.reportPerformance(10, 20, 30, 40, 50);
    SbeStatsReport update2 = new SbeStatsReport();
    update2.setDeviceCurrentBytes(new long[] { 3, 4 });
    update2.reportIterationCount(20);
    update2.reportIDs("sid2", "tid2", "wid2", 123456);
    update2.reportPerformance(11, 21, 31, 40, 50);
    StorageMetaData smd1 = new SbeStorageMetaData(123, "sid", "typeid", "wid", "initTypeClass", "updaterTypeClass");
    StorageMetaData smd2 = new SbeStorageMetaData(456, "sid2", "typeid2", "wid2", "initTypeClass2", "updaterTypeClass2");
    SbeStatsInitializationReport init1 = new SbeStatsInitializationReport();
    init1.reportIDs("sid", "wid", "tid", 3145253452L);
    init1.reportHardwareInfo(1, 2, 3, 4, null, null, "2344253");
    remoteRouter.putUpdate(update1);
    Thread.sleep(100);
    remoteRouter.putStorageMetaData(smd1);
    Thread.sleep(100);
    remoteRouter.putStaticInfo(init1);
    Thread.sleep(100);
    remoteRouter.putUpdate(update2);
    Thread.sleep(100);
    remoteRouter.putStorageMetaData(smd2);
    Thread.sleep(2000);
    assertEquals(2, metaData.size());
    assertEquals(2, updates.size());
    assertEquals(1, staticInfo.size());
    assertEquals(Arrays.asList(update1, update2), updates);
    assertEquals(Arrays.asList(smd1, smd2), metaData);
    assertEquals(Collections.singletonList(init1), staticInfo);
}
Also used : StorageMetaData(org.deeplearning4j.api.storage.StorageMetaData) SbeStorageMetaData(org.deeplearning4j.ui.storage.impl.SbeStorageMetaData) Persistable(org.deeplearning4j.api.storage.Persistable) SbeStatsInitializationReport(org.deeplearning4j.ui.stats.impl.SbeStatsInitializationReport) SbeStatsReport(org.deeplearning4j.ui.stats.impl.SbeStatsReport) UIServer(org.deeplearning4j.ui.api.UIServer) ArrayList(java.util.ArrayList) CollectionStatsStorageRouter(org.deeplearning4j.api.storage.impl.CollectionStatsStorageRouter) RemoteUIStatsStorageRouter(org.deeplearning4j.api.storage.impl.RemoteUIStatsStorageRouter) SbeStorageMetaData(org.deeplearning4j.ui.storage.impl.SbeStorageMetaData) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 5 with UIServer

use of org.deeplearning4j.ui.api.UIServer in project deeplearning4j by deeplearning4j.

the class TestRemoteReceiver method startRemoteUI.

@Test
@Ignore
public void startRemoteUI() throws Exception {
    UIServer s = UIServer.getInstance();
    s.enableRemoteListener();
    Thread.sleep(1000000);
}
Also used : UIServer(org.deeplearning4j.ui.api.UIServer) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

UIServer (org.deeplearning4j.ui.api.UIServer)8 Ignore (org.junit.Ignore)7 Test (org.junit.Test)7 StatsStorage (org.deeplearning4j.api.storage.StatsStorage)5 IrisDataSetIterator (org.deeplearning4j.datasets.iterator.impl.IrisDataSetIterator)5 StatsListener (org.deeplearning4j.ui.stats.StatsListener)5 InMemoryStatsStorage (org.deeplearning4j.ui.storage.InMemoryStatsStorage)5 DataSetIterator (org.nd4j.linalg.dataset.api.iterator.DataSetIterator)5 MultiLayerConfiguration (org.deeplearning4j.nn.conf.MultiLayerConfiguration)4 MultiLayerNetwork (org.deeplearning4j.nn.multilayer.MultiLayerNetwork)4 ScoreIterationListener (org.deeplearning4j.optimize.listeners.ScoreIterationListener)4 OutputLayer (org.deeplearning4j.nn.conf.layers.OutputLayer)3 Persistable (org.deeplearning4j.api.storage.Persistable)2 ArrayList (java.util.ArrayList)1 StorageMetaData (org.deeplearning4j.api.storage.StorageMetaData)1 CollectionStatsStorageRouter (org.deeplearning4j.api.storage.impl.CollectionStatsStorageRouter)1 RemoteUIStatsStorageRouter (org.deeplearning4j.api.storage.impl.RemoteUIStatsStorageRouter)1 EarlyStoppingConfiguration (org.deeplearning4j.earlystopping.EarlyStoppingConfiguration)1 InMemoryModelSaver (org.deeplearning4j.earlystopping.saver.InMemoryModelSaver)1 DataSetLossCalculator (org.deeplearning4j.earlystopping.scorecalc.DataSetLossCalculator)1