learn_gd: Learn Gradient Descent

Description Usage Arguments References Examples

View source: R/learn_gd.R

Description

Learn Gradient Descent

Usage

1
learn_gd(X, y, alpha, hiddenSize)

Arguments

X

input data

y

output data

alpha

fraction of gradient descent

hiddenSize

size of the hidden layer

References

http://qua.st/handcoding-gradient-descent/ http://iamtrask.github.io/2015/07/27/python-network-part2/

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# input dataset
X = matrix(c(0,0,1,
             0,1,1,
             1,0,1,
             1,1,1), nrow=4, byrow=TRUE)

# output dataset
y = matrix(c(0,
             1,
             1,
             0), nrow=4)

# set parameters
alpha = 0.1
hiddenSize = 32
# also try using:
# alphas = c(0.001,0.01,0.1,1,10,100,1000)
# for (alpha in alphas) {
#   print(paste("Training With Alpha", alpha))
#   learn_gd(X, y, alpha, hiddenSize)         }

# run gradient descent function
learn_gd(X, y, alpha, hiddenSize)

learNN documentation built on May 29, 2017, 9 a.m.