In [1]:
#NN.jl testbed
include("src\\NN.jl")
using NN, PyPlot


INFO: Loading help data...

In [116]:
x = rand(1,10000)-0.5#linspace(-0.5,0.5,100)#(rand(1,10000)-0.5)
f = (x)->x
#f = (x)->exp(x)
f = (x)->x.*x.*x
f = (x)->sin(x)
f = (x)->x.*x+1
#f = (x)->sin(exp(x.*x.*x-x+12)).^2
y = f(x)


Out[116]:
1x10000 Array{Float64,2}:
 1.04838  1.17642  1.02142  1.00452  …  1.06455  1.02304  1.04592  1.10441

In [123]:
nn = buildNN([1;10;10;1],0.00001,minimum(y),maximum(y),neuron_type="relu",reg_type="L2",verbose=false,init_type="rand",output_neuron_type="none")


Out[123]:
NeuralNetwork(NNWeights{2}([2=>10x10 Array{Float64,2}:
  0.416201   -0.296306   -0.414982   …   0.0509821  -1.08676     -0.302827 
  0.128851    0.227967    0.490191      -0.692485   -0.980554     0.919048 
  0.995047    0.95148     0.158678      -0.32418     0.879222    -0.313877 
 -0.391171   -0.228579   -0.810661      -0.576314    0.490153    -0.0772815
 -0.683108   -0.0722595  -1.01475        0.84992    -0.219344     0.0958978
 -0.691207    0.360633   -1.02577    …  -1.05388    -0.153408    -0.829053 
  1.0842      0.855658   -0.0749996     -0.35014    -0.850404    -0.529575 
 -0.434242    0.525127    0.302103       0.36922     0.0884638   -0.439862 
 -0.78658    -0.365586   -0.254382       0.470097    0.714839     0.630166 
 -0.0800814  -0.797861    0.671809       0.109932    0.00576992  -0.792697 ,3=>1x10 Array{Float64,2}:
 0.139038  -0.694917  0.944305  …  -0.408498  -0.856841  -0.000806853,1=>10x1 Array{Float64,2}:
  0.107526
  0.142827
 -0.177759
 -0.303342
 -0.311822
  0.318791
 -0.173962
  0.27806 
 -0.15185 
  0.15864 ]),NNWeights{1}([2=>[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],3=>[0.0],1=>[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]]),reLu,GreLu,(anonymous function),(anonymous function),1.0e-5,"L2",[1.24999],[1.0],[0.0],[0.0],false)

In [124]:
alpha_final = 0.1


Out[124]:
0.1

In [ ]:
nn,losses, losses_true,alpha_final = train(x,y,nn,alpha=alpha_final,num_epochs=100,minibatch_size=100000,update_type="nesterov",half_rate=5)


Epoch 1
Epoch 2
Epoch 3
Epoch 4
Epoch 5
Epoch 6
Epoch 7
Epoch 8
Epoch 9
Epoch 10
Epoch 11
Epoch 12
Epoch 13
Epoch 14
Epoch 15
Epoch 16
Epoch 17
Epoch 18
Epoch 19
Epoch 20
Epoch 21
Epoch 22
Epoch 23
Epoch 24
Epoch 25
Epoch 26
Epoch 27
Epoch 28
Epoch 29
Epoch 30
Epoch 31
Epoch 32
Epoch 33
Epoch 34
Epoch 35
Epoch 36
Epoch 37
Epoch 38
Epoch 39
Epoch 40
Epoch 41
Epoch 42
Epoch 43
Epoch 44
Epoch 45
Epoch 46
Epoch 47
Epoch 48
Epoch 49
Epoch 50
Epoch 51
Epoch 52

In [ ]:
x_ = linspace(-0.5,0.5,100)
y_ = [predict(nn,[x_[i]]) for i = 1:length(x_)]
#plotting stuff
plot(x_,f(x_),x_,y_)

In [ ]:
plot(losses)

In [ ]:
plot(losses_true)

In [ ]: