The documentation for Keras in R has shown multiple methods to initialise weights of a neural network. However, the method of customising the initialisation is not clear.
For example, I have a 3*3 neural network (or LSTM), I want to initialise weights by using my own 3*3 matrix. How can I do that in R?
Related
My neural network code is built through keras. I am obtaining very large loss function values, so I want to observe how the neural network output progresses per epoch in hopes of finding out what's wrong with my model.
Does keras have a function that returns the predicted values every iteration during gradient descent?
I am trying to implement a simple case of deep Q learning in R, using the neuralnet package.
I have an initial network with initial random weights. I use it to generate some experience for my agent and as a result, I get states and targets. Then I fit the states to the target and get a new network with new weights.
How do I have to combine the new weights and the initial weights? Do I simply keep the new weights and discard the initial weights?
is there any way I can display an image or diagram of my neural net using h20 in R. Also, I went through the h20 documentation but couldn't figure out to extract weights from the neural net object.
In h2o.deeplearning() set export_weights_and_biases=T and then once your model has finished building you can extract the weights with h2o.weights(). H2O doesn't provide methods to display a diagram for your neural net.
Hi I am a newbie in Depp learning fields.
I ran a neural network model (regression) with 2 hidden layers in R (neuralnet Package). then I used the the compute function to get the predicted probabilities.Now I want to regenerate predicted output using the equation used in the neural net. for example, following are weights received from the model object
Intercept.to.1layhid1 4.55725020215
Var1.to.1layhid1 -13.61221477737
VAr2.to.1layhid1 0.30686384857
var1.to.1layhid2 0.23527690062
var2.to.1layhid2 0..67345678
1layhid.1.to.target 1.95414397785
1layhid.2.to.target 3.68009136857
Can any one help me derive a equation with the above weights so that I can replicate the output
Thanks
In order to get the output for new data, you can always use predict function using the fitted model, which is the returned object from neuralnet function.
For instance, if your model is the following:
neuralFit = neuralnet(trainData)
Then you reproduce the output with the following:
predict(neuralFit,newdata)
Otherwise, you'll need to compute the result manually. But you need to understand your network architecture first.
I am using R along with the neuralnet package see docs (https://cran.r-project.org/web/packages/neuralnet/neuralnet.pdf). I have used the neural network function to build and train my model.
Now I have built my model I want to test it on real data. Could someone explain if I should use the compute or prediction function? I have read the documentation and it isnt clear, both functions seem to do similar?
Thanks
The short answer is to use compute to do predictions.
You can see an example of using compute on the test set here. We can also see that compute is the right one from the documentation:
compute, a method for objects of class nn, typically produced by neuralnet. Computes the outputs
of all neurons for specific arbitrary covariate vectors given a trained neural network.
The above says that you can use covariate vectors in order to compute the output of the neural network i.e. make a prediction.
On the other hand prediction does what is mentioned in the title in the documentation:
Summarizes the output of the neural network, the data and the fitted
values of glm objects (if available)
Moreover, it only takes two arguments: the nn object and a list of glm models so there isn't a way to pass in the test set in order to make a prediction.