ND4J;使用带有计算梯度的更新程序/优化程序

时间:2018-10-11 05:16:34

标签: java deep-learning deeplearning4j nd4j

我正在尝试将ND4j Adam优化器用于基于ND4J SameDiff自动微分实现的目标。我不想使用DeepLearning4j的NeuralNetConfiguration.Builder()ComputationGraph,我只想使用带有通过某些自定义代码计算的某些渐变的更新程序/优化程序。

我发现我们可以使用类似于下面的内容

// list of parameters to be optimized 
SDVariable[] params; // I have this already initialized. 

// list of gradients computed for each parameter in params
INDArray gradients; // I have computed already computed this

// now I want to use above variables to perform a single gradient descent step based on Adam optimizer
// based on the source code, we can use something similar to below
Adam adam = Adam.builder().build();
GradientUpdater updater = adam.instantiate(INDArray viewArray, boolean initializeViewArray);
updater.applyUpdater(INDArray gradient, int iteration, int epoch);

但是我不确定应该为每个参数设置什么值。尤其是viewArrayinitializeViewArray参数是什么?

如果有人可以帮助我了解最好的方法,我将不胜感激。 谢谢!!!

0 个答案:

没有答案