- Java Deep Learning Projects
- Md. Rezaul Karim
- 259字
- 2021-06-18 19:08:07
Output layer
The number of input neurons is equal to the output of the hidden layer 1. Then the number of outputs is equal to the number of predicted labels. We set a smaller value yet again, considering a very few inputs and features.
Here we used the Softmax activation function, which gives us a probability distribution over classes (the outputs sum to 1.0), and the losses function as cross-entropy for binary classification (XNET) since we want to convert the output (probability) to a discrete class, that is, zero or one:
OutputLayer output_layer = new OutputLayer.Builder(LossFunction.XENT) // XENT for Binary Classification
.weightInit(WeightInit.XAVIER)
.activation(Activation.SOFTMAX)
.nIn(16).nOut(numOutputs)
.build();
XNET is used for binary classification with logistic regression. Check out more about this in LossFunctions.java class in DL4J.
Now we create a MultiLayerConfiguration by specifying NeuralNetConfiguration before conducting the training. With DL4J, we can add a layer by calling layer on the NeuralNetConfiguration.Builder(), specifying its place in the order of layers (the zero-indexed layer in the following code is the input layer):
MultiLayerConfiguration MLPconf = new NeuralNetConfiguration.Builder().seed(seed)
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
.weightInit(WeightInit.XAVIER)
.updater(new Adam(0.0001))
.list()
.layer(0, input_layer)
.layer(1, hidden_layer_1)
.layer(2, hidden_layer_2)
.layer(3, output_layer)
.pretrain(false).backprop(true).build();// no pre-traning required
Apart from these, we also specify how to set the network's weights. For example, as discussed, we use Xavier as the weight initialization and Stochastic Gradient Descent (SGD) optimization algorithm with Adam as the updater. Finally, we also specify that we do not need to do any pre-training (which is typically needed in DBN or stacked autoencoders). Nevertheless, since MLP is a feedforward network, we set backpropagation as true.
- Hands-On Deep Learning with Apache Spark
- 軟件架構(gòu)設(shè)計
- AWS:Security Best Practices on AWS
- R Machine Learning By Example
- 數(shù)控銑削(加工中心)編程與加工
- 大數(shù)據(jù)挑戰(zhàn)與NoSQL數(shù)據(jù)庫技術(shù)
- 工業(yè)機(jī)器人維護(hù)與保養(yǎng)
- HTML5 Canvas Cookbook
- SAP Business Intelligence Quick Start Guide
- 基于企業(yè)網(wǎng)站的顧客感知服務(wù)質(zhì)量評價理論模型與實證研究
- 啊哈C!思考快你一步
- 在實戰(zhàn)中成長:C++開發(fā)之路
- AI的25種可能
- INSTANT Adobe Story Starter
- AMK伺服控制系統(tǒng)原理及應(yīng)用