/** Calculate the output of the network, with masking arrays. The masking arrays are used in situations such * as one-to-many and many-to-one recurrent neural network (RNN) designs, as well as for supporting time series * of varying lengths within the same minibatch. */ public INDArray output(INDArray input, boolean train, INDArray featuresMask, INDArray labelsMask) { WorkspaceMode cMode = layerWiseConfigurations.getTrainingWorkspaceMode(); layerWiseConfigurations.setTrainingWorkspaceMode(layerWiseConfigurations.getInferenceWorkspaceMode()); MemoryWorkspace workspace = layerWiseConfigurations.getTrainingWorkspaceMode() == WorkspaceMode.NONE ? new DummyWorkspace() : Nd4j.getWorkspaceManager().getWorkspaceForCurrentThread( workspaceConfigurationExternal, workspaceExternal); try (MemoryWorkspace wsE = workspace.notifyScopeEntered()) { INDArray ret = silentOutput(input, train, featuresMask, labelsMask).detach(); layerWiseConfigurations.setTrainingWorkspaceMode(cMode); return ret; } }
/** * Label the probabilities of the input * * @param input the input to label * @param train whether the output * is test or train. This mainly * affect hyper parameters such as * drop out where certain things should * be applied with activations * @return a vector of probabilities * given each label. * <p> * This is typically of the form: * [0.5, 0.5] or some other probability distribution summing to one */ public INDArray output(INDArray input, boolean train) { WorkspaceMode cMode = layerWiseConfigurations.getTrainingWorkspaceMode(); layerWiseConfigurations.setTrainingWorkspaceMode(layerWiseConfigurations.getInferenceWorkspaceMode()); MemoryWorkspace workspace = layerWiseConfigurations.getTrainingWorkspaceMode() == WorkspaceMode.NONE ? new DummyWorkspace() : Nd4j.getWorkspaceManager().getWorkspaceForCurrentThread( workspaceConfigurationExternal, workspaceExternal); try (MemoryWorkspace wsE = workspace.notifyScopeEntered()) { INDArray ret = silentOutput(input, train).detach(); layerWiseConfigurations.setTrainingWorkspaceMode(cMode); return ret; } }
MultiLayerConfiguration conf = MultiLayerConfiguration.fromJson( ((MultiLayerNetwork) originalModel).getLayerWiseConfigurations().toJson()); conf.setTrainingWorkspaceMode(workspaceMode); this.replicatedModel = new MultiLayerNetwork(conf); .setTrainingWorkspaceMode(workspaceMode);
MultiLayerConfiguration conf = MultiLayerConfiguration.fromJson( ((MultiLayerNetwork) originalModel).getLayerWiseConfigurations().toJson()); conf.setTrainingWorkspaceMode(workspaceMode); this.replicatedModel = new MultiLayerNetwork(conf); .setTrainingWorkspaceMode(workspaceMode);
layerWiseConfigurations.setTrainingWorkspaceMode(layerWiseConfigurations.getInferenceWorkspaceMode()); ((AsyncDataSetIterator) iter).shutdown(); layerWiseConfigurations.setTrainingWorkspaceMode(cMode);