@Test public void testCliRunner() throws Exception { ArbiterCliRunner cliRunner = new ArbiterCliRunner(); MultiLayerSpace mls = new MultiLayerSpace.Builder() .optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT) .updater(new SgdSpace(new ContinuousParameterSpace(0.0001, 0.1))) .l2(new ContinuousParameterSpace(0.0001, 0.01)) .addLayer(new DenseLayerSpace.Builder().nIn(784).nOut(new IntegerParameterSpace(2,10)) .activation(new DiscreteParameterSpace<>(Activation.RELU, Activation.TANH)) .build()) .addLayer(new OutputLayerSpace.Builder().nOut(10).activation(Activation.SOFTMAX) .lossFunction(LossFunctions.LossFunction.MCXENT).build()) .numEpochs(3).build(); assertEquals(mls,MultiLayerSpace.fromJson(mls.toJson())); Map<String,Object> commands = new HashMap<>(); commands.put(DataSetIteratorFactoryProvider.FACTORY_KEY,TestDataFactoryProviderMnist.class.getCanonicalName()); CandidateGenerator candidateGenerator = new RandomSearchGenerator(mls,commands); DataProvider dataProvider = new DataSetIteratorFactoryProvider(); String modelSavePath = new File(System.getProperty("java.io.tmpdir"),"ArbiterDL4JTest/").getAbsolutePath(); File dir = new File(modelSavePath); if(!dir.exists()) dir.mkdirs(); String configPath = System.getProperty("java.io.tmpdir") + File.separator + UUID.randomUUID().toString() + ".json"; OptimizationConfiguration configuration = new OptimizationConfiguration.Builder() .candidateGenerator(candidateGenerator) .dataProvider(dataProvider) .modelSaver(new FileModelSaver(modelSavePath)) .scoreFunction(new TestSetLossScoreFunction()) .terminationConditions(new MaxTimeCondition(30, TimeUnit.SECONDS), new MaxCandidatesCondition(5)) .build(); assertEquals(configuration,OptimizationConfiguration.fromJson(configuration.toJson())); FileUtils.writeStringToFile(new File(configPath),configuration.toJson()); configuration.toJson(); log.info("Starting test"); cliRunner.runMain( "--dataSetIteratorClass", TestDataFactoryProviderMnist.class.getCanonicalName(), "--neuralNetType", ArbiterCliRunner.MULTI_LAYER_NETWORK, "--optimizationConfigPath", configPath ); }
public void runMain(String...args) throws Exception { JCommander jcmdr = new JCommander(this); try { jcmdr.parse(args); } catch(ParameterException e) { System.err.println(e.getMessage()); jcmdr.usage(); try{ Thread.sleep(500); } catch(Exception e2){ } System.exit(1); } Map<String,Object> commands = new HashMap<>(); commands.put(DataSetIteratorFactoryProvider.FACTORY_KEY,dataSetIteratorClass); File f = new File(modelSavePath); if(f.exists()) f.delete(); f.mkdir(); f.deleteOnExit(); if(problemType.equals(REGRESSION)) { if(neuralNetType.equals(COMP_GRAPH)) { OptimizationConfiguration configuration = OptimizationConfiguration.fromJson( FileUtils.readFileToString(new File(optimizationConfigPath))); IOptimizationRunner runner = new LocalOptimizationRunner(configuration, new ComputationGraphTaskCreator( new RegressionDataEvaluator(RegressionValue.valueOf(regressionType),commands))); runner.execute(); } else if(neuralNetType.equals(MULTI_LAYER_NETWORK)) { OptimizationConfiguration configuration = OptimizationConfiguration. fromJson(FileUtils.readFileToString(new File(optimizationConfigPath))); IOptimizationRunner runner = new LocalOptimizationRunner( configuration, new MultiLayerNetworkTaskCreator( new RegressionDataEvaluator( RegressionValue.valueOf(regressionType), commands))); runner.execute(); } } else if(problemType.equals(CLASSIFICATION)) { if(neuralNetType.equals(COMP_GRAPH)) { OptimizationConfiguration configuration = OptimizationConfiguration.fromJson(FileUtils.readFileToString(new File(optimizationConfigPath))); IOptimizationRunner runner = new LocalOptimizationRunner( configuration,new ComputationGraphTaskCreator(new ClassificationEvaluator())); runner.execute(); } else if(neuralNetType.equals(MULTI_LAYER_NETWORK)) { OptimizationConfiguration configuration = OptimizationConfiguration .fromJson(FileUtils.readFileToString(new File(optimizationConfigPath))); IOptimizationRunner runner = new LocalOptimizationRunner(configuration, new MultiLayerNetworkTaskCreator( new ClassificationEvaluator()) ); runner.execute(); } } }
ArbiterCliRunner { public void runMain(String...args) throws Exception { JCommander jcmdr = new JCommander(this); try { jcmdr.parse(args); } catch(ParameterException e) { System.err.println(e.getMessage()); jcmdr.usage(); try{ Thread.sleep(500); } catch(Exception e2){ } System.exit(1); } Map<String,Object> commands = new HashMap<>(); commands.put(DataSetIteratorFactoryProvider.FACTORY_KEY,dataSetIteratorClass); File f = new File(modelSavePath); if(f.exists()) f.delete(); f.mkdir(); f.deleteOnExit(); if(problemType.equals(REGRESSION)) { if(neuralNetType.equals(COMP_GRAPH)) { OptimizationConfiguration configuration = OptimizationConfiguration.fromJson( FileUtils.readFileToString(new File(optimizationConfigPath))); IOptimizationRunner runner = new LocalOptimizationRunner(configuration, new ComputationGraphTaskCreator( new RegressionDataEvaluator(RegressionValue.valueOf(regressionType),commands))); runner.execute(); } else if(neuralNetType.equals(MULTI_LAYER_NETWORK)) { OptimizationConfiguration configuration = OptimizationConfiguration. fromJson(FileUtils.readFileToString(new File(optimizationConfigPath))); IOptimizationRunner runner = new LocalOptimizationRunner( configuration, new MultiLayerNetworkTaskCreator( new RegressionDataEvaluator( RegressionValue.valueOf(regressionType), commands))); runner.execute(); } } else if(problemType.equals(CLASSIFICATION)) { if(neuralNetType.equals(COMP_GRAPH)) { OptimizationConfiguration configuration = OptimizationConfiguration.fromJson(FileUtils.readFileToString(new File(optimizationConfigPath))); IOptimizationRunner runner = new LocalOptimizationRunner( configuration,new ComputationGraphTaskCreator(new ClassificationEvaluator())); runner.execute(); } else if(neuralNetType.equals(MULTI_LAYER_NETWORK)) { OptimizationConfiguration configuration = OptimizationConfiguration .fromJson(FileUtils.readFileToString(new File(optimizationConfigPath))); IOptimizationRunner runner = new LocalOptimizationRunner(configuration, new MultiLayerNetworkTaskCreator( new ClassificationEvaluator()) ); runner.execute(); } } } }
ArbiterCliRunner { public void runMain(String...args) throws Exception { JCommander jcmdr = new JCommander(this); try { jcmdr.parse(args); } catch(ParameterException e) { System.err.println(e.getMessage()); jcmdr.usage(); try{ Thread.sleep(500); } catch(Exception e2){ } System.exit(1); } Map<String,Object> commands = new HashMap<>(); commands.put(DataSetIteratorFactoryProvider.FACTORY_KEY,dataSetIteratorClass); File f = new File(modelSavePath); if(f.exists()) f.delete(); f.mkdir(); f.deleteOnExit(); if(problemType.equals(REGRESSION)) { if(neuralNetType.equals(COMP_GRAPH)) { OptimizationConfiguration configuration = OptimizationConfiguration.fromJson( FileUtils.readFileToString(new File(optimizationConfigPath))); IOptimizationRunner runner = new LocalOptimizationRunner(configuration, new ComputationGraphTaskCreator( new RegressionDataEvaluator(RegressionValue.valueOf(regressionType),commands))); runner.execute(); } else if(neuralNetType.equals(MULTI_LAYER_NETWORK)) { OptimizationConfiguration configuration = OptimizationConfiguration. fromJson(FileUtils.readFileToString(new File(optimizationConfigPath))); IOptimizationRunner runner = new LocalOptimizationRunner( configuration, new MultiLayerNetworkTaskCreator( new RegressionDataEvaluator( RegressionValue.valueOf(regressionType), commands))); runner.execute(); } } else if(problemType.equals(CLASSIFICATION)) { if(neuralNetType.equals(COMP_GRAPH)) { OptimizationConfiguration configuration = OptimizationConfiguration.fromJson(FileUtils.readFileToString(new File(optimizationConfigPath))); IOptimizationRunner runner = new LocalOptimizationRunner( configuration,new ComputationGraphTaskCreator(new ClassificationEvaluator())); runner.execute(); } else if(neuralNetType.equals(MULTI_LAYER_NETWORK)) { OptimizationConfiguration configuration = OptimizationConfiguration .fromJson(FileUtils.readFileToString(new File(optimizationConfigPath))); IOptimizationRunner runner = new LocalOptimizationRunner(configuration, new MultiLayerNetworkTaskCreator( new ClassificationEvaluator()) ); runner.execute(); } } }  }
ArbiterCliRunner { public void runMain(String...args) throws Exception { JCommander jcmdr = new JCommander(this); try { jcmdr.parse(args); } catch(ParameterException e) { System.err.println(e.getMessage()); jcmdr.usage(); try{ Thread.sleep(500); } catch(Exception e2){ } System.exit(1); } Map<String,Object> commands = new HashMap<>(); commands.put(DataSetIteratorFactoryProvider.FACTORY_KEY,dataSetIteratorClass); File f = new File(modelSavePath); if(f.exists()) f.delete(); f.mkdir(); f.deleteOnExit(); if(problemType.equals(REGRESSION)) { if(neuralNetType.equals(COMP_GRAPH)) { OptimizationConfiguration configuration = OptimizationConfiguration.fromJson( FileUtils.readFileToString(new File(optimizationConfigPath))); IOptimizationRunner runner = new LocalOptimizationRunner(configuration, new ComputationGraphTaskCreator( new RegressionDataEvaluator(RegressionValue.valueOf(regressionType),commands))); runner.execute(); } else if(neuralNetType.equals(MULTI_LAYER_NETWORK)) { OptimizationConfiguration configuration = OptimizationConfiguration. fromJson(FileUtils.readFileToString(new File(optimizationConfigPath))); IOptimizationRunner runner = new LocalOptimizationRunner( configuration, new MultiLayerNetworkTaskCreator( new RegressionDataEvaluator( RegressionValue.valueOf(regressionType), commands))); runner.execute(); } } else if(problemType.equals(CLASSIFICATION)) { if(neuralNetType.equals(COMP_GRAPH)) { OptimizationConfiguration configuration = OptimizationConfiguration.fromJson(FileUtils.readFileToString(new File(optimizationConfigPath))); IOptimizationRunner runner = new LocalOptimizationRunner( configuration,new ComputationGraphTaskCreator(new ClassificationEvaluator())); runner.execute(); } else if(neuralNetType.equals(MULTI_LAYER_NETWORK)) { OptimizationConfiguration configuration = OptimizationConfiguration .fromJson(FileUtils.readFileToString(new File(optimizationConfigPath))); IOptimizationRunner runner = new LocalOptimizationRunner(configuration, new MultiLayerNetworkTaskCreator( new ClassificationEvaluator()) ); runner.execute(); } } }  void runMain(String...args); static void main(String...args); }
ArbiterCliRunner { public void runMain(String...args) throws Exception { JCommander jcmdr = new JCommander(this); try { jcmdr.parse(args); } catch(ParameterException e) { System.err.println(e.getMessage()); jcmdr.usage(); try{ Thread.sleep(500); } catch(Exception e2){ } System.exit(1); } Map<String,Object> commands = new HashMap<>(); commands.put(DataSetIteratorFactoryProvider.FACTORY_KEY,dataSetIteratorClass); File f = new File(modelSavePath); if(f.exists()) f.delete(); f.mkdir(); f.deleteOnExit(); if(problemType.equals(REGRESSION)) { if(neuralNetType.equals(COMP_GRAPH)) { OptimizationConfiguration configuration = OptimizationConfiguration.fromJson( FileUtils.readFileToString(new File(optimizationConfigPath))); IOptimizationRunner runner = new LocalOptimizationRunner(configuration, new ComputationGraphTaskCreator( new RegressionDataEvaluator(RegressionValue.valueOf(regressionType),commands))); runner.execute(); } else if(neuralNetType.equals(MULTI_LAYER_NETWORK)) { OptimizationConfiguration configuration = OptimizationConfiguration. fromJson(FileUtils.readFileToString(new File(optimizationConfigPath))); IOptimizationRunner runner = new LocalOptimizationRunner( configuration, new MultiLayerNetworkTaskCreator( new RegressionDataEvaluator( RegressionValue.valueOf(regressionType), commands))); runner.execute(); } } else if(problemType.equals(CLASSIFICATION)) { if(neuralNetType.equals(COMP_GRAPH)) { OptimizationConfiguration configuration = OptimizationConfiguration.fromJson(FileUtils.readFileToString(new File(optimizationConfigPath))); IOptimizationRunner runner = new LocalOptimizationRunner( configuration,new ComputationGraphTaskCreator(new ClassificationEvaluator())); runner.execute(); } else if(neuralNetType.equals(MULTI_LAYER_NETWORK)) { OptimizationConfiguration configuration = OptimizationConfiguration .fromJson(FileUtils.readFileToString(new File(optimizationConfigPath))); IOptimizationRunner runner = new LocalOptimizationRunner(configuration, new MultiLayerNetworkTaskCreator( new ClassificationEvaluator()) ); runner.execute(); } } }  void runMain(String...args); static void main(String...args); final static String CLASSIFICATION; final static String REGRESSION; final static String COMP_GRAPH; final static String MULTI_LAYER_NETWORK; }