In [26]:
%pylab inline
import keras
import numpy as np
Populating the interactive namespace from numpy and matplotlib
Input signal. Single training example.
In [27]:
t = np.arange(50).reshape(1, -1)
x = np.sin(2*np.pi/50*t)
print(x.shape)
plot(t[0], x[0]);
(1, 50)
Simple autoencoder of four layers: 50 -> 25 -> 12 -> 25 -> 50.
In [28]:
from keras.models import Sequential
from keras.layers import containers
from keras.layers.core import Dense, AutoEncoder
encoder = containers.Sequential([Dense(25, input_dim=50), Dense(12)])
decoder = containers.Sequential([Dense(25, input_dim=12), Dense(50)])
model = Sequential()
model.add(AutoEncoder(encoder=encoder, decoder=decoder, output_reconstruction=True))
model.compile(loss='mean_squared_error', optimizer='sgd')
In [29]:
# prediction with initial weight should be random
plot(model.predict(x)[0]);
In [30]:
# train the model and store the loss values as function of time
from loss_history import LossHistory
loss_history = LossHistory()
model.fit(x, x, nb_epoch=500, batch_size=1, callbacks=[loss_history])
Epoch 1/500
1/1 [==============================] - 0s - loss: 0.9343
Epoch 2/500
1/1 [==============================] - 0s - loss: 0.8351
Epoch 3/500
1/1 [==============================] - 0s - loss: 0.7614
Epoch 4/500
1/1 [==============================] - 0s - loss: 0.7052
Epoch 5/500
1/1 [==============================] - 0s - loss: 0.6615
Epoch 6/500
1/1 [==============================] - 0s - loss: 0.6269
Epoch 7/500
1/1 [==============================] - 0s - loss: 0.5992
Epoch 8/500
1/1 [==============================] - 0s - loss: 0.5766
Epoch 9/500
1/1 [==============================] - 0s - loss: 0.5581
Epoch 10/500
1/1 [==============================] - 0s - loss: 0.5426
Epoch 11/500
1/1 [==============================] - 0s - loss: 0.5297
Epoch 12/500
1/1 [==============================] - 0s - loss: 0.5187
Epoch 13/500
1/1 [==============================] - 0s - loss: 0.5092
Epoch 14/500
1/1 [==============================] - 0s - loss: 0.5011
Epoch 15/500
1/1 [==============================] - 0s - loss: 0.4940
Epoch 16/500
1/1 [==============================] - 0s - loss: 0.4877
Epoch 17/500
1/1 [==============================] - 0s - loss: 0.4822
Epoch 18/500
1/1 [==============================] - 0s - loss: 0.4772
Epoch 19/500
1/1 [==============================] - 0s - loss: 0.4728
Epoch 20/500
1/1 [==============================] - 0s - loss: 0.4687
Epoch 21/500
1/1 [==============================] - 0s - loss: 0.4650
Epoch 22/500
1/1 [==============================] - 0s - loss: 0.4616
Epoch 23/500
1/1 [==============================] - 0s - loss: 0.4584
Epoch 24/500
1/1 [==============================] - 0s - loss: 0.4554
Epoch 25/500
1/1 [==============================] - 0s - loss: 0.4526
Epoch 26/500
1/1 [==============================] - 0s - loss: 0.4500
Epoch 27/500
1/1 [==============================] - 0s - loss: 0.4475
Epoch 28/500
1/1 [==============================] - 0s - loss: 0.4451
Epoch 29/500
1/1 [==============================] - 0s - loss: 0.4428
Epoch 30/500
1/1 [==============================] - 0s - loss: 0.4406
Epoch 31/500
1/1 [==============================] - 0s - loss: 0.4385
Epoch 32/500
1/1 [==============================] - 0s - loss: 0.4364
Epoch 33/500
1/1 [==============================] - 0s - loss: 0.4344
Epoch 34/500
1/1 [==============================] - 0s - loss: 0.4324
Epoch 35/500
1/1 [==============================] - 0s - loss: 0.4305
Epoch 36/500
1/1 [==============================] - 0s - loss: 0.4286
Epoch 37/500
1/1 [==============================] - 0s - loss: 0.4268
Epoch 38/500
1/1 [==============================] - 0s - loss: 0.4250
Epoch 39/500
1/1 [==============================] - 0s - loss: 0.4232
Epoch 40/500
1/1 [==============================] - 0s - loss: 0.4214
Epoch 41/500
1/1 [==============================] - 0s - loss: 0.4196
Epoch 42/500
1/1 [==============================] - 0s - loss: 0.4179
Epoch 43/500
1/1 [==============================] - 0s - loss: 0.4162
Epoch 44/500
1/1 [==============================] - 0s - loss: 0.4145
Epoch 45/500
1/1 [==============================] - 0s - loss: 0.4127
Epoch 46/500
1/1 [==============================] - 0s - loss: 0.4110
Epoch 47/500
1/1 [==============================] - 0s - loss: 0.4094
Epoch 48/500
1/1 [==============================] - 0s - loss: 0.4077
Epoch 49/500
1/1 [==============================] - 0s - loss: 0.4060
Epoch 50/500
1/1 [==============================] - 0s - loss: 0.4043
Epoch 51/500
1/1 [==============================] - 0s - loss: 0.4027
Epoch 52/500
1/1 [==============================] - 0s - loss: 0.4010
Epoch 53/500
1/1 [==============================] - 0s - loss: 0.3993
Epoch 54/500
1/1 [==============================] - 0s - loss: 0.3976
Epoch 55/500
1/1 [==============================] - 0s - loss: 0.3960
Epoch 56/500
1/1 [==============================] - 0s - loss: 0.3943
Epoch 57/500
1/1 [==============================] - 0s - loss: 0.3926
Epoch 58/500
1/1 [==============================] - 0s - loss: 0.3910
Epoch 59/500
1/1 [==============================] - 0s - loss: 0.3893
Epoch 60/500
1/1 [==============================] - 0s - loss: 0.3876
Epoch 61/500
1/1 [==============================] - 0s - loss: 0.3859
Epoch 62/500
1/1 [==============================] - 0s - loss: 0.3842
Epoch 63/500
1/1 [==============================] - 0s - loss: 0.3826
Epoch 64/500
1/1 [==============================] - 0s - loss: 0.3809
Epoch 65/500
1/1 [==============================] - 0s - loss: 0.3792
Epoch 66/500
1/1 [==============================] - 0s - loss: 0.3775
Epoch 67/500
1/1 [==============================] - 0s - loss: 0.3758
Epoch 68/500
1/1 [==============================] - 0s - loss: 0.3741
Epoch 69/500
1/1 [==============================] - 0s - loss: 0.3723
Epoch 70/500
1/1 [==============================] - 0s - loss: 0.3706
Epoch 71/500
1/1 [==============================] - 0s - loss: 0.3689
Epoch 72/500
1/1 [==============================] - 0s - loss: 0.3672
Epoch 73/500
1/1 [==============================] - 0s - loss: 0.3654
Epoch 74/500
1/1 [==============================] - 0s - loss: 0.3637
Epoch 75/500
1/1 [==============================] - 0s - loss: 0.3619
Epoch 76/500
1/1 [==============================] - 0s - loss: 0.3602
Epoch 77/500
1/1 [==============================] - 0s - loss: 0.3584
Epoch 78/500
1/1 [==============================] - 0s - loss: 0.3566
Epoch 79/500
1/1 [==============================] - 0s - loss: 0.3549
Epoch 80/500
1/1 [==============================] - 0s - loss: 0.3531
Epoch 81/500
1/1 [==============================] - 0s - loss: 0.3513
Epoch 82/500
1/1 [==============================] - 0s - loss: 0.3495
Epoch 83/500
1/1 [==============================] - 0s - loss: 0.3477
Epoch 84/500
1/1 [==============================] - 0s - loss: 0.3459
Epoch 85/500
1/1 [==============================] - 0s - loss: 0.3441
Epoch 86/500
1/1 [==============================] - 0s - loss: 0.3423
Epoch 87/500
1/1 [==============================] - 0s - loss: 0.3404
Epoch 88/500
1/1 [==============================] - 0s - loss: 0.3386
Epoch 89/500
1/1 [==============================] - 0s - loss: 0.3367
Epoch 90/500
1/1 [==============================] - 0s - loss: 0.3349
Epoch 91/500
1/1 [==============================] - 0s - loss: 0.3330
Epoch 92/500
1/1 [==============================] - 0s - loss: 0.3312
Epoch 93/500
1/1 [==============================] - 0s - loss: 0.3293
Epoch 94/500
1/1 [==============================] - 0s - loss: 0.3274
Epoch 95/500
1/1 [==============================] - 0s - loss: 0.3255
Epoch 96/500
1/1 [==============================] - 0s - loss: 0.3236
Epoch 97/500
1/1 [==============================] - 0s - loss: 0.3217
Epoch 98/500
1/1 [==============================] - 0s - loss: 0.3198
Epoch 99/500
1/1 [==============================] - 0s - loss: 0.3179
Epoch 100/500
1/1 [==============================] - 0s - loss: 0.3160
Epoch 101/500
1/1 [==============================] - 0s - loss: 0.3141
Epoch 102/500
1/1 [==============================] - 0s - loss: 0.3122
Epoch 103/500
1/1 [==============================] - 0s - loss: 0.3102
Epoch 104/500
1/1 [==============================] - 0s - loss: 0.3083
Epoch 105/500
1/1 [==============================] - 0s - loss: 0.3063
Epoch 106/500
1/1 [==============================] - 0s - loss: 0.3044
Epoch 107/500
1/1 [==============================] - 0s - loss: 0.3024
Epoch 108/500
1/1 [==============================] - 0s - loss: 0.3004
Epoch 109/500
1/1 [==============================] - 0s - loss: 0.2985
Epoch 110/500
1/1 [==============================] - 0s - loss: 0.2965
Epoch 111/500
1/1 [==============================] - 0s - loss: 0.2945
Epoch 112/500
1/1 [==============================] - 0s - loss: 0.2925
Epoch 113/500
1/1 [==============================] - 0s - loss: 0.2905
Epoch 114/500
1/1 [==============================] - 0s - loss: 0.2885
Epoch 115/500
1/1 [==============================] - 0s - loss: 0.2865
Epoch 116/500
1/1 [==============================] - 0s - loss: 0.2845
Epoch 117/500
1/1 [==============================] - 0s - loss: 0.2825
Epoch 118/500
1/1 [==============================] - 0s - loss: 0.2805
Epoch 119/500
1/1 [==============================] - 0s - loss: 0.2785
Epoch 120/500
1/1 [==============================] - 0s - loss: 0.2764
Epoch 121/500
1/1 [==============================] - 0s - loss: 0.2744
Epoch 122/500
1/1 [==============================] - 0s - loss: 0.2724
Epoch 123/500
1/1 [==============================] - 0s - loss: 0.2703
Epoch 124/500
1/1 [==============================] - 0s - loss: 0.2683
Epoch 125/500
1/1 [==============================] - 0s - loss: 0.2663
Epoch 126/500
1/1 [==============================] - 0s - loss: 0.2642
Epoch 127/500
1/1 [==============================] - 0s - loss: 0.2622
Epoch 128/500
1/1 [==============================] - 0s - loss: 0.2601
Epoch 129/500
1/1 [==============================] - 0s - loss: 0.2581
Epoch 130/500
1/1 [==============================] - 0s - loss: 0.2560
Epoch 131/500
1/1 [==============================] - 0s - loss: 0.2539
Epoch 132/500
1/1 [==============================] - 0s - loss: 0.2519
Epoch 133/500
1/1 [==============================] - 0s - loss: 0.2498
Epoch 134/500
1/1 [==============================] - 0s - loss: 0.2478
Epoch 135/500
1/1 [==============================] - 0s - loss: 0.2457
Epoch 136/500
1/1 [==============================] - 0s - loss: 0.2437
Epoch 137/500
1/1 [==============================] - 0s - loss: 0.2416
Epoch 138/500
1/1 [==============================] - 0s - loss: 0.2395
Epoch 139/500
1/1 [==============================] - 0s - loss: 0.2375
Epoch 140/500
1/1 [==============================] - 0s - loss: 0.2354
Epoch 141/500
1/1 [==============================] - 0s - loss: 0.2334
Epoch 142/500
1/1 [==============================] - 0s - loss: 0.2313
Epoch 143/500
1/1 [==============================] - 0s - loss: 0.2292
Epoch 144/500
1/1 [==============================] - 0s - loss: 0.2272
Epoch 145/500
1/1 [==============================] - 0s - loss: 0.2251
Epoch 146/500
1/1 [==============================] - 0s - loss: 0.2231
Epoch 147/500
1/1 [==============================] - 0s - loss: 0.2210
Epoch 148/500
1/1 [==============================] - 0s - loss: 0.2190
Epoch 149/500
1/1 [==============================] - 0s - loss: 0.2170
Epoch 150/500
1/1 [==============================] - 0s - loss: 0.2149
Epoch 151/500
1/1 [==============================] - 0s - loss: 0.2129
Epoch 152/500
1/1 [==============================] - 0s - loss: 0.2109
Epoch 153/500
1/1 [==============================] - 0s - loss: 0.2088
Epoch 154/500
1/1 [==============================] - 0s - loss: 0.2068
Epoch 155/500
1/1 [==============================] - 0s - loss: 0.2048
Epoch 156/500
1/1 [==============================] - 0s - loss: 0.2028
Epoch 157/500
1/1 [==============================] - 0s - loss: 0.2008
Epoch 158/500
1/1 [==============================] - 0s - loss: 0.1988
Epoch 159/500
1/1 [==============================] - 0s - loss: 0.1968
Epoch 160/500
1/1 [==============================] - 0s - loss: 0.1948
Epoch 161/500
1/1 [==============================] - 0s - loss: 0.1928
Epoch 162/500
1/1 [==============================] - 0s - loss: 0.1908
Epoch 163/500
1/1 [==============================] - 0s - loss: 0.1888
Epoch 164/500
1/1 [==============================] - 0s - loss: 0.1869
Epoch 165/500
1/1 [==============================] - 0s - loss: 0.1849
Epoch 166/500
1/1 [==============================] - 0s - loss: 0.1830
Epoch 167/500
1/1 [==============================] - 0s - loss: 0.1810
Epoch 168/500
1/1 [==============================] - 0s - loss: 0.1791
Epoch 169/500
1/1 [==============================] - 0s - loss: 0.1772
Epoch 170/500
1/1 [==============================] - 0s - loss: 0.1753
Epoch 171/500
1/1 [==============================] - 0s - loss: 0.1734
Epoch 172/500
1/1 [==============================] - 0s - loss: 0.1715
Epoch 173/500
1/1 [==============================] - 0s - loss: 0.1696
Epoch 174/500
1/1 [==============================] - 0s - loss: 0.1677
Epoch 175/500
1/1 [==============================] - 0s - loss: 0.1658
Epoch 176/500
1/1 [==============================] - 0s - loss: 0.1640
Epoch 177/500
1/1 [==============================] - 0s - loss: 0.1621
Epoch 178/500
1/1 [==============================] - 0s - loss: 0.1603
Epoch 179/500
1/1 [==============================] - 0s - loss: 0.1584
Epoch 180/500
1/1 [==============================] - 0s - loss: 0.1566
Epoch 181/500
1/1 [==============================] - 0s - loss: 0.1548
Epoch 182/500
1/1 [==============================] - 0s - loss: 0.1530
Epoch 183/500
1/1 [==============================] - 0s - loss: 0.1512
Epoch 184/500
1/1 [==============================] - 0s - loss: 0.1495
Epoch 185/500
1/1 [==============================] - 0s - loss: 0.1477
Epoch 186/500
1/1 [==============================] - 0s - loss: 0.1459
Epoch 187/500
1/1 [==============================] - 0s - loss: 0.1442
Epoch 188/500
1/1 [==============================] - 0s - loss: 0.1425
Epoch 189/500
1/1 [==============================] - 0s - loss: 0.1408
Epoch 190/500
1/1 [==============================] - 0s - loss: 0.1391
Epoch 191/500
1/1 [==============================] - 0s - loss: 0.1374
Epoch 192/500
1/1 [==============================] - 0s - loss: 0.1357
Epoch 193/500
1/1 [==============================] - 0s - loss: 0.1340
Epoch 194/500
1/1 [==============================] - 0s - loss: 0.1324
Epoch 195/500
1/1 [==============================] - 0s - loss: 0.1307
Epoch 196/500
1/1 [==============================] - 0s - loss: 0.1291
Epoch 197/500
1/1 [==============================] - 0s - loss: 0.1275
Epoch 198/500
1/1 [==============================] - 0s - loss: 0.1259
Epoch 199/500
1/1 [==============================] - 0s - loss: 0.1243
Epoch 200/500
1/1 [==============================] - 0s - loss: 0.1227
Epoch 201/500
1/1 [==============================] - 0s - loss: 0.1212
Epoch 202/500
1/1 [==============================] - 0s - loss: 0.1196
Epoch 203/500
1/1 [==============================] - 0s - loss: 0.1181
Epoch 204/500
1/1 [==============================] - 0s - loss: 0.1166
Epoch 205/500
1/1 [==============================] - 0s - loss: 0.1151
Epoch 206/500
1/1 [==============================] - 0s - loss: 0.1136
Epoch 207/500
1/1 [==============================] - 0s - loss: 0.1121
Epoch 208/500
1/1 [==============================] - 0s - loss: 0.1106
Epoch 209/500
1/1 [==============================] - 0s - loss: 0.1092
Epoch 210/500
1/1 [==============================] - 0s - loss: 0.1078
Epoch 211/500
1/1 [==============================] - 0s - loss: 0.1063
Epoch 212/500
1/1 [==============================] - 0s - loss: 0.1049
Epoch 213/500
1/1 [==============================] - 0s - loss: 0.1035
Epoch 214/500
1/1 [==============================] - 0s - loss: 0.1022
Epoch 215/500
1/1 [==============================] - 0s - loss: 0.1008
Epoch 216/500
1/1 [==============================] - 0s - loss: 0.0994
Epoch 217/500
1/1 [==============================] - 0s - loss: 0.0981
Epoch 218/500
1/1 [==============================] - 0s - loss: 0.0968
Epoch 219/500
1/1 [==============================] - 0s - loss: 0.0955
Epoch 220/500
1/1 [==============================] - 0s - loss: 0.0942
Epoch 221/500
1/1 [==============================] - 0s - loss: 0.0929
Epoch 222/500
1/1 [==============================] - 0s - loss: 0.0916
Epoch 223/500
1/1 [==============================] - 0s - loss: 0.0904
Epoch 224/500
1/1 [==============================] - 0s - loss: 0.0891
Epoch 225/500
1/1 [==============================] - 0s - loss: 0.0879
Epoch 226/500
1/1 [==============================] - 0s - loss: 0.0867
Epoch 227/500
1/1 [==============================] - 0s - loss: 0.0855
Epoch 228/500
1/1 [==============================] - 0s - loss: 0.0843
Epoch 229/500
1/1 [==============================] - 0s - loss: 0.0831
Epoch 230/500
1/1 [==============================] - 0s - loss: 0.0820
Epoch 231/500
1/1 [==============================] - 0s - loss: 0.0808
Epoch 232/500
1/1 [==============================] - 0s - loss: 0.0797
Epoch 233/500
1/1 [==============================] - 0s - loss: 0.0786
Epoch 234/500
1/1 [==============================] - 0s - loss: 0.0775
Epoch 235/500
1/1 [==============================] - 0s - loss: 0.0764
Epoch 236/500
1/1 [==============================] - 0s - loss: 0.0753
Epoch 237/500
1/1 [==============================] - 0s - loss: 0.0742
Epoch 238/500
1/1 [==============================] - 0s - loss: 0.0732
Epoch 239/500
1/1 [==============================] - 0s - loss: 0.0721
Epoch 240/500
1/1 [==============================] - 0s - loss: 0.0711
Epoch 241/500
1/1 [==============================] - 0s - loss: 0.0701
Epoch 242/500
1/1 [==============================] - 0s - loss: 0.0691
Epoch 243/500
1/1 [==============================] - 0s - loss: 0.0681
Epoch 244/500
1/1 [==============================] - 0s - loss: 0.0671
Epoch 245/500
1/1 [==============================] - 0s - loss: 0.0662
Epoch 246/500
1/1 [==============================] - 0s - loss: 0.0652
Epoch 247/500
1/1 [==============================] - 0s - loss: 0.0643
Epoch 248/500
1/1 [==============================] - 0s - loss: 0.0633
Epoch 249/500
1/1 [==============================] - 0s - loss: 0.0624
Epoch 250/500
1/1 [==============================] - 0s - loss: 0.0615
Epoch 251/500
1/1 [==============================] - 0s - loss: 0.0606
Epoch 252/500
1/1 [==============================] - 0s - loss: 0.0597
Epoch 253/500
1/1 [==============================] - 0s - loss: 0.0589
Epoch 254/500
1/1 [==============================] - 0s - loss: 0.0580
Epoch 255/500
1/1 [==============================] - 0s - loss: 0.0571
Epoch 256/500
1/1 [==============================] - 0s - loss: 0.0563
Epoch 257/500
1/1 [==============================] - 0s - loss: 0.0555
Epoch 258/500
1/1 [==============================] - 0s - loss: 0.0547
Epoch 259/500
1/1 [==============================] - 0s - loss: 0.0539
Epoch 260/500
1/1 [==============================] - 0s - loss: 0.0531
Epoch 261/500
1/1 [==============================] - 0s - loss: 0.0523
Epoch 262/500
1/1 [==============================] - 0s - loss: 0.0515
Epoch 263/500
1/1 [==============================] - 0s - loss: 0.0508
Epoch 264/500
1/1 [==============================] - 0s - loss: 0.0500
Epoch 265/500
1/1 [==============================] - 0s - loss: 0.0493
Epoch 266/500
1/1 [==============================] - 0s - loss: 0.0485
Epoch 267/500
1/1 [==============================] - 0s - loss: 0.0478
Epoch 268/500
1/1 [==============================] - 0s - loss: 0.0471
Epoch 269/500
1/1 [==============================] - 0s - loss: 0.0464
Epoch 270/500
1/1 [==============================] - 0s - loss: 0.0457
Epoch 271/500
1/1 [==============================] - 0s - loss: 0.0450
Epoch 272/500
1/1 [==============================] - 0s - loss: 0.0444
Epoch 273/500
1/1 [==============================] - 0s - loss: 0.0437
Epoch 274/500
1/1 [==============================] - 0s - loss: 0.0430
Epoch 275/500
1/1 [==============================] - 0s - loss: 0.0424
Epoch 276/500
1/1 [==============================] - 0s - loss: 0.0418
Epoch 277/500
1/1 [==============================] - 0s - loss: 0.0411
Epoch 278/500
1/1 [==============================] - 0s - loss: 0.0405
Epoch 279/500
1/1 [==============================] - 0s - loss: 0.0399
Epoch 280/500
1/1 [==============================] - 0s - loss: 0.0393
Epoch 281/500
1/1 [==============================] - 0s - loss: 0.0387
Epoch 282/500
1/1 [==============================] - 0s - loss: 0.0381
Epoch 283/500
1/1 [==============================] - 0s - loss: 0.0376
Epoch 284/500
1/1 [==============================] - 0s - loss: 0.0370
Epoch 285/500
1/1 [==============================] - 0s - loss: 0.0364
Epoch 286/500
1/1 [==============================] - 0s - loss: 0.0359
Epoch 287/500
1/1 [==============================] - 0s - loss: 0.0353
Epoch 288/500
1/1 [==============================] - 0s - loss: 0.0348
Epoch 289/500
1/1 [==============================] - 0s - loss: 0.0343
Epoch 290/500
1/1 [==============================] - 0s - loss: 0.0338
Epoch 291/500
1/1 [==============================] - 0s - loss: 0.0332
Epoch 292/500
1/1 [==============================] - 0s - loss: 0.0327
Epoch 293/500
1/1 [==============================] - 0s - loss: 0.0322
Epoch 294/500
1/1 [==============================] - 0s - loss: 0.0318
Epoch 295/500
1/1 [==============================] - 0s - loss: 0.0313
Epoch 296/500
1/1 [==============================] - 0s - loss: 0.0308
Epoch 297/500
1/1 [==============================] - 0s - loss: 0.0303
Epoch 298/500
1/1 [==============================] - 0s - loss: 0.0299
Epoch 299/500
1/1 [==============================] - 0s - loss: 0.0294
Epoch 300/500
1/1 [==============================] - 0s - loss: 0.0290
Epoch 301/500
1/1 [==============================] - 0s - loss: 0.0285
Epoch 302/500
1/1 [==============================] - 0s - loss: 0.0281
Epoch 303/500
1/1 [==============================] - 0s - loss: 0.0276
Epoch 304/500
1/1 [==============================] - 0s - loss: 0.0272
Epoch 305/500
1/1 [==============================] - 0s - loss: 0.0268
Epoch 306/500
1/1 [==============================] - 0s - loss: 0.0264
Epoch 307/500
1/1 [==============================] - 0s - loss: 0.0260
Epoch 308/500
1/1 [==============================] - 0s - loss: 0.0256
Epoch 309/500
1/1 [==============================] - 0s - loss: 0.0252
Epoch 310/500
1/1 [==============================] - 0s - loss: 0.0248
Epoch 311/500
1/1 [==============================] - 0s - loss: 0.0244
Epoch 312/500
1/1 [==============================] - 0s - loss: 0.0241
Epoch 313/500
1/1 [==============================] - 0s - loss: 0.0237
Epoch 314/500
1/1 [==============================] - 0s - loss: 0.0233
Epoch 315/500
1/1 [==============================] - 0s - loss: 0.0230
Epoch 316/500
1/1 [==============================] - 0s - loss: 0.0226
Epoch 317/500
1/1 [==============================] - 0s - loss: 0.0223
Epoch 318/500
1/1 [==============================] - 0s - loss: 0.0219
Epoch 319/500
1/1 [==============================] - 0s - loss: 0.0216
Epoch 320/500
1/1 [==============================] - 0s - loss: 0.0213
Epoch 321/500
1/1 [==============================] - 0s - loss: 0.0209
Epoch 322/500
1/1 [==============================] - 0s - loss: 0.0206
Epoch 323/500
1/1 [==============================] - 0s - loss: 0.0203
Epoch 324/500
1/1 [==============================] - 0s - loss: 0.0200
Epoch 325/500
1/1 [==============================] - 0s - loss: 0.0197
Epoch 326/500
1/1 [==============================] - 0s - loss: 0.0194
Epoch 327/500
1/1 [==============================] - 0s - loss: 0.0191
Epoch 328/500
1/1 [==============================] - 0s - loss: 0.0188
Epoch 329/500
1/1 [==============================] - 0s - loss: 0.0185
Epoch 330/500
1/1 [==============================] - 0s - loss: 0.0182
Epoch 331/500
1/1 [==============================] - 0s - loss: 0.0179
Epoch 332/500
1/1 [==============================] - 0s - loss: 0.0176
Epoch 333/500
1/1 [==============================] - 0s - loss: 0.0174
Epoch 334/500
1/1 [==============================] - 0s - loss: 0.0171
Epoch 335/500
1/1 [==============================] - 0s - loss: 0.0168
Epoch 336/500
1/1 [==============================] - 0s - loss: 0.0166
Epoch 337/500
1/1 [==============================] - 0s - loss: 0.0163
Epoch 338/500
1/1 [==============================] - 0s - loss: 0.0161
Epoch 339/500
1/1 [==============================] - 0s - loss: 0.0158
Epoch 340/500
1/1 [==============================] - 0s - loss: 0.0156
Epoch 341/500
1/1 [==============================] - 0s - loss: 0.0153
Epoch 342/500
1/1 [==============================] - 0s - loss: 0.0151
Epoch 343/500
1/1 [==============================] - 0s - loss: 0.0149
Epoch 344/500
1/1 [==============================] - 0s - loss: 0.0146
Epoch 345/500
1/1 [==============================] - 0s - loss: 0.0144
Epoch 346/500
1/1 [==============================] - 0s - loss: 0.0142
Epoch 347/500
1/1 [==============================] - 0s - loss: 0.0139
Epoch 348/500
1/1 [==============================] - 0s - loss: 0.0137
Epoch 349/500
1/1 [==============================] - 0s - loss: 0.0135
Epoch 350/500
1/1 [==============================] - 0s - loss: 0.0133
Epoch 351/500
1/1 [==============================] - 0s - loss: 0.0131
Epoch 352/500
1/1 [==============================] - 0s - loss: 0.0129
Epoch 353/500
1/1 [==============================] - 0s - loss: 0.0127
Epoch 354/500
1/1 [==============================] - 0s - loss: 0.0125
Epoch 355/500
1/1 [==============================] - 0s - loss: 0.0123
Epoch 356/500
1/1 [==============================] - 0s - loss: 0.0121
Epoch 357/500
1/1 [==============================] - 0s - loss: 0.0119
Epoch 358/500
1/1 [==============================] - 0s - loss: 0.0117
Epoch 359/500
1/1 [==============================] - 0s - loss: 0.0116
Epoch 360/500
1/1 [==============================] - 0s - loss: 0.0114
Epoch 361/500
1/1 [==============================] - 0s - loss: 0.0112
Epoch 362/500
1/1 [==============================] - 0s - loss: 0.0110
Epoch 363/500
1/1 [==============================] - 0s - loss: 0.0109
Epoch 364/500
1/1 [==============================] - 0s - loss: 0.0107
Epoch 365/500
1/1 [==============================] - 0s - loss: 0.0105
Epoch 366/500
1/1 [==============================] - 0s - loss: 0.0104
Epoch 367/500
1/1 [==============================] - 0s - loss: 0.0102
Epoch 368/500
1/1 [==============================] - 0s - loss: 0.0100
Epoch 369/500
1/1 [==============================] - 0s - loss: 0.0099
Epoch 370/500
1/1 [==============================] - 0s - loss: 0.0097
Epoch 371/500
1/1 [==============================] - 0s - loss: 0.0096
Epoch 372/500
1/1 [==============================] - 0s - loss: 0.0094
Epoch 373/500
1/1 [==============================] - 0s - loss: 0.0093
Epoch 374/500
1/1 [==============================] - 0s - loss: 0.0091
Epoch 375/500
1/1 [==============================] - 0s - loss: 0.0090
Epoch 376/500
1/1 [==============================] - 0s - loss: 0.0088
Epoch 377/500
1/1 [==============================] - 0s - loss: 0.0087
Epoch 378/500
1/1 [==============================] - 0s - loss: 0.0086
Epoch 379/500
1/1 [==============================] - 0s - loss: 0.0084
Epoch 380/500
1/1 [==============================] - 0s - loss: 0.0083
Epoch 381/500
1/1 [==============================] - 0s - loss: 0.0082
Epoch 382/500
1/1 [==============================] - 0s - loss: 0.0081
Epoch 383/500
1/1 [==============================] - 0s - loss: 0.0079
Epoch 384/500
1/1 [==============================] - 0s - loss: 0.0078
Epoch 385/500
1/1 [==============================] - 0s - loss: 0.0077
Epoch 386/500
1/1 [==============================] - 0s - loss: 0.0076
Epoch 387/500
1/1 [==============================] - 0s - loss: 0.0074
Epoch 388/500
1/1 [==============================] - 0s - loss: 0.0073
Epoch 389/500
1/1 [==============================] - 0s - loss: 0.0072
Epoch 390/500
1/1 [==============================] - 0s - loss: 0.0071
Epoch 391/500
1/1 [==============================] - 0s - loss: 0.0070
Epoch 392/500
1/1 [==============================] - 0s - loss: 0.0069
Epoch 393/500
1/1 [==============================] - 0s - loss: 0.0068
Epoch 394/500
1/1 [==============================] - 0s - loss: 0.0067
Epoch 395/500
1/1 [==============================] - 0s - loss: 0.0066
Epoch 396/500
1/1 [==============================] - 0s - loss: 0.0065
Epoch 397/500
1/1 [==============================] - 0s - loss: 0.0064
Epoch 398/500
1/1 [==============================] - 0s - loss: 0.0063
Epoch 399/500
1/1 [==============================] - 0s - loss: 0.0062
Epoch 400/500
1/1 [==============================] - 0s - loss: 0.0061
Epoch 401/500
1/1 [==============================] - 0s - loss: 0.0060
Epoch 402/500
1/1 [==============================] - 0s - loss: 0.0059
Epoch 403/500
1/1 [==============================] - 0s - loss: 0.0058
Epoch 404/500
1/1 [==============================] - 0s - loss: 0.0057
Epoch 405/500
1/1 [==============================] - 0s - loss: 0.0056
Epoch 406/500
1/1 [==============================] - 0s - loss: 0.0055
Epoch 407/500
1/1 [==============================] - 0s - loss: 0.0054
Epoch 408/500
1/1 [==============================] - 0s - loss: 0.0053
Epoch 409/500
1/1 [==============================] - 0s - loss: 0.0053
Epoch 410/500
1/1 [==============================] - 0s - loss: 0.0052
Epoch 411/500
1/1 [==============================] - 0s - loss: 0.0051
Epoch 412/500
1/1 [==============================] - 0s - loss: 0.0050
Epoch 413/500
1/1 [==============================] - 0s - loss: 0.0049
Epoch 414/500
1/1 [==============================] - 0s - loss: 0.0049
Epoch 415/500
1/1 [==============================] - 0s - loss: 0.0048
Epoch 416/500
1/1 [==============================] - 0s - loss: 0.0047
Epoch 417/500
1/1 [==============================] - 0s - loss: 0.0046
Epoch 418/500
1/1 [==============================] - 0s - loss: 0.0046
Epoch 419/500
1/1 [==============================] - 0s - loss: 0.0045
Epoch 420/500
1/1 [==============================] - 0s - loss: 0.0044
Epoch 421/500
1/1 [==============================] - 0s - loss: 0.0044
Epoch 422/500
1/1 [==============================] - 0s - loss: 0.0043
Epoch 423/500
1/1 [==============================] - 0s - loss: 0.0042
Epoch 424/500
1/1 [==============================] - 0s - loss: 0.0042
Epoch 425/500
1/1 [==============================] - 0s - loss: 0.0041
Epoch 426/500
1/1 [==============================] - 0s - loss: 0.0040
Epoch 427/500
1/1 [==============================] - 0s - loss: 0.0040
Epoch 428/500
1/1 [==============================] - 0s - loss: 0.0039
Epoch 429/500
1/1 [==============================] - 0s - loss: 0.0038
Epoch 430/500
1/1 [==============================] - 0s - loss: 0.0038
Epoch 431/500
1/1 [==============================] - 0s - loss: 0.0037
Epoch 432/500
1/1 [==============================] - 0s - loss: 0.0037
Epoch 433/500
1/1 [==============================] - 0s - loss: 0.0036
Epoch 434/500
1/1 [==============================] - 0s - loss: 0.0036
Epoch 435/500
1/1 [==============================] - 0s - loss: 0.0035
Epoch 436/500
1/1 [==============================] - 0s - loss: 0.0034
Epoch 437/500
1/1 [==============================] - 0s - loss: 0.0034
Epoch 438/500
1/1 [==============================] - 0s - loss: 0.0033
Epoch 439/500
1/1 [==============================] - 0s - loss: 0.0033
Epoch 440/500
1/1 [==============================] - 0s - loss: 0.0032
Epoch 441/500
1/1 [==============================] - 0s - loss: 0.0032
Epoch 442/500
1/1 [==============================] - 0s - loss: 0.0031
Epoch 443/500
1/1 [==============================] - 0s - loss: 0.0031
Epoch 444/500
1/1 [==============================] - 0s - loss: 0.0030
Epoch 445/500
1/1 [==============================] - 0s - loss: 0.0030
Epoch 446/500
1/1 [==============================] - 0s - loss: 0.0029
Epoch 447/500
1/1 [==============================] - 0s - loss: 0.0029
Epoch 448/500
1/1 [==============================] - 0s - loss: 0.0028
Epoch 449/500
1/1 [==============================] - 0s - loss: 0.0028
Epoch 450/500
1/1 [==============================] - 0s - loss: 0.0028
Epoch 451/500
1/1 [==============================] - 0s - loss: 0.0027
Epoch 452/500
1/1 [==============================] - 0s - loss: 0.0027
Epoch 453/500
1/1 [==============================] - 0s - loss: 0.0026
Epoch 454/500
1/1 [==============================] - 0s - loss: 0.0026
Epoch 455/500
1/1 [==============================] - 0s - loss: 0.0026
Epoch 456/500
1/1 [==============================] - 0s - loss: 0.0025
Epoch 457/500
1/1 [==============================] - 0s - loss: 0.0025
Epoch 458/500
1/1 [==============================] - 0s - loss: 0.0024
Epoch 459/500
1/1 [==============================] - 0s - loss: 0.0024
Epoch 460/500
1/1 [==============================] - 0s - loss: 0.0024
Epoch 461/500
1/1 [==============================] - 0s - loss: 0.0023
Epoch 462/500
1/1 [==============================] - 0s - loss: 0.0023
Epoch 463/500
1/1 [==============================] - 0s - loss: 0.0022
Epoch 464/500
1/1 [==============================] - 0s - loss: 0.0022
Epoch 465/500
1/1 [==============================] - 0s - loss: 0.0022
Epoch 466/500
1/1 [==============================] - 0s - loss: 0.0021
Epoch 467/500
1/1 [==============================] - 0s - loss: 0.0021
Epoch 468/500
1/1 [==============================] - 0s - loss: 0.0021
Epoch 469/500
1/1 [==============================] - 0s - loss: 0.0020
Epoch 470/500
1/1 [==============================] - 0s - loss: 0.0020
Epoch 471/500
1/1 [==============================] - 0s - loss: 0.0020
Epoch 472/500
1/1 [==============================] - 0s - loss: 0.0020
Epoch 473/500
1/1 [==============================] - 0s - loss: 0.0019
Epoch 474/500
1/1 [==============================] - 0s - loss: 0.0019
Epoch 475/500
1/1 [==============================] - 0s - loss: 0.0019
Epoch 476/500
1/1 [==============================] - 0s - loss: 0.0018
Epoch 477/500
1/1 [==============================] - 0s - loss: 0.0018
Epoch 478/500
1/1 [==============================] - 0s - loss: 0.0018
Epoch 479/500
1/1 [==============================] - 0s - loss: 0.0017
Epoch 480/500
1/1 [==============================] - 0s - loss: 0.0017
Epoch 481/500
1/1 [==============================] - 0s - loss: 0.0017
Epoch 482/500
1/1 [==============================] - 0s - loss: 0.0017
Epoch 483/500
1/1 [==============================] - 0s - loss: 0.0016
Epoch 484/500
1/1 [==============================] - 0s - loss: 0.0016
Epoch 485/500
1/1 [==============================] - 0s - loss: 0.0016
Epoch 486/500
1/1 [==============================] - 0s - loss: 0.0016
Epoch 487/500
1/1 [==============================] - 0s - loss: 0.0015
Epoch 488/500
1/1 [==============================] - 0s - loss: 0.0015
Epoch 489/500
1/1 [==============================] - 0s - loss: 0.0015
Epoch 490/500
1/1 [==============================] - 0s - loss: 0.0015
Epoch 491/500
1/1 [==============================] - 0s - loss: 0.0014
Epoch 492/500
1/1 [==============================] - 0s - loss: 0.0014
Epoch 493/500
1/1 [==============================] - 0s - loss: 0.0014
Epoch 494/500
1/1 [==============================] - 0s - loss: 0.0014
Epoch 495/500
1/1 [==============================] - 0s - loss: 0.0014
Epoch 496/500
1/1 [==============================] - 0s - loss: 0.0013
Epoch 497/500
1/1 [==============================] - 0s - loss: 0.0013
Epoch 498/500
1/1 [==============================] - 0s - loss: 0.0013
Epoch 499/500
1/1 [==============================] - 0s - loss: 0.0013
Epoch 500/500
1/1 [==============================] - 0s - loss: 0.0013
Out[30]:
<keras.callbacks.History at 0x10b09b320>
In [31]:
plot(loss_history.losses);
In [32]:
plot(log10(loss_history.losses));
The model fits the data quite nicely.
In [33]:
plot(model.predict(x)[0])
plot(x[0]);
The model is able to predict on noise-corrupted data.
In [34]:
x_noised = x + 0.2 * np.random.random(len(x[0]))
plot(x_noised[0], label='input')
plot(model.predict(x_noised)[0], label='predicted')
legend();
However the model does is not able to predict a sinusoid with different phase.
In [35]:
x_shifted = np.cos(2*np.pi/50*t)
plot(x_shifted[0], label='input')
plot(model.predict(x_shifted)[0], label='predicted')
legend();
The model is able to deal with scaled sinuoid, but the farther it is from the original amplitude, the more noise.
In [36]:
x_scaled = 0.2 * x
plot(x_scaled[0], label='input')
plot(model.predict(x_scaled)[0], label='predicted')
legend();
Content source: bzamecnik/ml-playground
Similar notebooks: