# Create the models with 3 layers
model = dNNmodel(units=c(8, 6, 1), activation = c('elu', 'relu', 'sigmoid'),
input_shape = c(3))
print(model)
#
# Feed forward network with dummy data x
x = matrix(runif(15), nrow = 5, ncol = 3)
cache = fwdNN(x, model)
#
# Back propagation with dummy dy = dL/dyhat and minin batch for SGD
dy = as.matrix(runif(5, -0.1, 0.1), nrow = 5)
dW = bwdNN(dy, cache, model)
#
# Gradient descent with SGD
lr_rate = 0.0001
sgd = function(w, dw) {w-lr_rate*dw}
model$params = mapply(sgd, w = model$params, dw = dW)
Run the code above in your browser using DataLab