Commit 2eda7b39 authored by Mgr. Filip Münz PhD.'s avatar Mgr. Filip Münz PhD.
Browse files

ohnosan code

parent a45f47de
%% Cell type:code id: tags:
``` python
from tensorflow import config
config.list_physical_devices('GPU')
```
%% Output
[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
%% Cell type:code id: tags:
``` python
import numpy
#import matplotlib.pyplot as plt
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
nlayer=3
activ='sigmoid'
optim='adam'
xnorm_flag=1
ynorm_flag=1
ntrain=20000
nepochs=40
```
%% Cell type:code id: tags:
``` python
traindataset='D:/Data/time/lcurve2_1ms_pack%i.npz'
validdataset=traindataset%8
npz=[numpy.load(traindataset%i) for i in range(1,4)]
#npz=numpy.load(traindataset%1)
#xdata=npz['lc']
#ydata=npz['delay']
xdata=numpy.concatenate([[npq['set%s%i'%(str(j) if j>0 else "",i)] for i in range(1,10)] for j,npq in enumerate(npz)])
ydata=numpy.concatenate([[npq['del%s%i'%(str(j) if j>0 else "",i)] for i in range(1,10)] for j,npq in enumerate(npz)])
xmin,xmax=numpy.min(xdata),numpy.max(xdata)
if xnorm_flag == 1:
xdata=(xdata-xmin)/(xmax-xmin)
#xdata=xdata/numpy.max(xdata,axis=1)[:,numpy.newaxis]
ymin,ymax=numpy.min(ydata),numpy.max(ydata)
if ynorm_flag == 1:
ydata=(ydata-ymin)/(ymax-ymin)
xtrain=xdata[:ntrain]
ytrain=ydata[:ntrain]
npz_valid=numpy.load(validdataset)
j=8
xdata=numpy.concatenate([npz_valid['set%i%i'%(j-1,i)] for i in range(4)])
ydata=numpy.concatenate([npz_valid['del%i%i'%(j-1,i)] for i in range(4)])
#xdata=npz_valid['lc']
#ydata=npz_valid['delay']
xmin,xmax=numpy.min(xdata),numpy.max(xdata)
if xnorm_flag == 1:
xdata=(xdata-xmin)/(xmax-xmin)
#xdata=xdata/numpy.max(xdata,axis=1)[:,numpy.newaxis]
ymin,ymax=numpy.min(ydata),numpy.max(ydata)
if ynorm_flag == 1:
ydata=(ydata-ymin)/(ymax-ymin)
xvalid=xdata
yvalid=ydata
```
%% Cell type:code id: tags:
``` python
from neural import next# import train_me
next.xtrain,next.ytrain=xtrain,ytrain
next.xvalid,next.yvalid=xvalid,yvalid
```
%% Cell type:code id: tags:
``` python
model=next.train_me("D:/Data/")
model.save("D:/Data/model_%dlayer_%dtrain_%depochs_noynorm_%dpatterns_batch.h5"%(nlayer,ntrain,nepochs,npatterns))
```
%% Output
Epoch 1/100
WARNING:tensorflow:Model was constructed with shape (None, 10000) for input KerasTensor(type_spec=TensorSpec(shape=(None, 10000), dtype=tf.float32, name='dense_4_input'), name='dense_4_input', description="created by layer 'dense_4_input'"), but it was called on an input with incompatible shape (None, 1000, 10000).
WARNING:tensorflow:Model was constructed with shape (None, 10000) for input KerasTensor(type_spec=TensorSpec(shape=(None, 10000), dtype=tf.float32, name='dense_4_input'), name='dense_4_input', description="created by layer 'dense_4_input'"), but it was called on an input with incompatible shape (None, 1000, 10000).
1/1 [==============================] - 3s 3s/step - loss: 0.8164 - val_loss: 0.3632
Epoch 2/100
1/1 [==============================] - 0s 475ms/step - loss: 0.3784 - val_loss: 0.1531
Epoch 3/100
1/1 [==============================] - 0s 500ms/step - loss: 0.1630 - val_loss: 0.0880
Epoch 4/100
1/1 [==============================] - 0s 475ms/step - loss: 0.0901 - val_loss: 0.0908
Epoch 5/100
1/1 [==============================] - 1s 542ms/step - loss: 0.0870 - val_loss: 0.1164
Epoch 6/100
1/1 [==============================] - 1s 538ms/step - loss: 0.1092 - val_loss: 0.1431
Epoch 7/100
1/1 [==============================] - 1s 548ms/step - loss: 0.1343 - val_loss: 0.1620
Epoch 8/100
1/1 [==============================] - 1s 545ms/step - loss: 0.1526 - val_loss: 0.1711
Epoch 9/100
1/1 [==============================] - 1s 544ms/step - loss: 0.1619 - val_loss: 0.1715
Epoch 10/100
1/1 [==============================] - 1s 538ms/step - loss: 0.1627 - val_loss: 0.1653
Epoch 11/100
1/1 [==============================] - 1s 549ms/step - loss: 0.1571 - val_loss: 0.1547
Epoch 12/100
1/1 [==============================] - 1s 541ms/step - loss: 0.1472 - val_loss: 0.1416
Epoch 13/100
1/1 [==============================] - 1s 543ms/step - loss: 0.1350 - val_loss: 0.1279
Epoch 14/100
1/1 [==============================] - 1s 521ms/step - loss: 0.1221 - val_loss: 0.1150
Epoch 15/100
1/1 [==============================] - 1s 552ms/step - loss: 0.1099 - val_loss: 0.1037
Epoch 16/100
1/1 [==============================] - 1s 543ms/step - loss: 0.0995 - val_loss: 0.0947
Epoch 17/100
1/1 [==============================] - 1s 550ms/step - loss: 0.0914 - val_loss: 0.0884
Epoch 18/100
1/1 [==============================] - 1s 546ms/step - loss: 0.0859 - val_loss: 0.0847
Epoch 19/100
1/1 [==============================] - 1s 552ms/step - loss: 0.0830 - val_loss: 0.0833
Epoch 20/100
1/1 [==============================] - 1s 567ms/step - loss: 0.0824 - val_loss: 0.0838
Epoch 21/100
1/1 [==============================] - 1s 563ms/step - loss: 0.0835 - val_loss: 0.0854
Epoch 22/100
1/1 [==============================] - 1s 546ms/step - loss: 0.0856 - val_loss: 0.0876
Epoch 23/100
1/1 [==============================] - 1s 561ms/step - loss: 0.0882 - val_loss: 0.0897
Epoch 24/100
1/1 [==============================] - 1s 550ms/step - loss: 0.0907 - val_loss: 0.0913
Epoch 25/100
1/1 [==============================] - 1s 562ms/step - loss: 0.0925 - val_loss: 0.0921
Epoch 26/100
1/1 [==============================] - 1s 553ms/step - loss: 0.0934 - val_loss: 0.0921
Epoch 27/100
1/1 [==============================] - 1s 551ms/step - loss: 0.0934 - val_loss: 0.0913
Epoch 28/100
1/1 [==============================] - 1s 555ms/step - loss: 0.0925 - val_loss: 0.0900
Epoch 29/100
1/1 [==============================] - 1s 554ms/step - loss: 0.0909 - val_loss: 0.0883
Epoch 30/100
1/1 [==============================] - 1s 550ms/step - loss: 0.0891 - val_loss: 0.0866
Epoch 31/100
1/1 [==============================] - 1s 570ms/step - loss: 0.0871 - val_loss: 0.0851
Epoch 32/100
1/1 [==============================] - 1s 571ms/step - loss: 0.0852 - val_loss: 0.0839
Epoch 33/100
1/1 [==============================] - 1s 576ms/step - loss: 0.0837 - val_loss: 0.0831
Epoch 34/100
1/1 [==============================] - 1s 539ms/step - loss: 0.0826 - val_loss: 0.0828
Epoch 35/100
1/1 [==============================] - 1s 556ms/step - loss: 0.0820 - val_loss: 0.0828
Epoch 36/100
1/1 [==============================] - 1s 550ms/step - loss: 0.0818 - val_loss: 0.0832
Epoch 37/100
1/1 [==============================] - 1s 575ms/step - loss: 0.0818 - val_loss: 0.0837
Epoch 38/100
1/1 [==============================] - 1s 550ms/step - loss: 0.0822 - val_loss: 0.0843
Epoch 39/100
1/1 [==============================] - 1s 556ms/step - loss: 0.0826 - val_loss: 0.0849
Epoch 40/100
1/1 [==============================] - 1s 549ms/step - loss: 0.0830 - val_loss: 0.0853
Epoch 41/100
1/1 [==============================] - 1s 551ms/step - loss: 0.0833 - val_loss: 0.0855
Epoch 42/100
1/1 [==============================] - 1s 554ms/step - loss: 0.0835 - val_loss: 0.0856
Epoch 43/100
1/1 [==============================] - 1s 553ms/step - loss: 0.0835 - val_loss: 0.0854
Epoch 44/100
1/1 [==============================] - 1s 517ms/step - loss: 0.0834 - val_loss: 0.0851
Epoch 45/100
1/1 [==============================] - 1s 563ms/step - loss: 0.0831 - val_loss: 0.0846
Epoch 46/100
1/1 [==============================] - 1s 548ms/step - loss: 0.0827 - val_loss: 0.0841
Epoch 47/100
1/1 [==============================] - 1s 549ms/step - loss: 0.0823 - val_loss: 0.0835
Epoch 48/100
1/1 [==============================] - 1s 557ms/step - loss: 0.0819 - val_loss: 0.0830
Epoch 49/100
1/1 [==============================] - 1s 554ms/step - loss: 0.0815 - val_loss: 0.0826
Epoch 50/100
1/1 [==============================] - 1s 553ms/step - loss: 0.0812 - val_loss: 0.0822
Epoch 51/100
1/1 [==============================] - 1s 544ms/step - loss: 0.0810 - val_loss: 0.0819
Epoch 52/100
1/1 [==============================] - 1s 568ms/step - loss: 0.0808 - val_loss: 0.0817
Epoch 53/100
1/1 [==============================] - 1s 572ms/step - loss: 0.0808 - val_loss: 0.0816
Epoch 54/100
1/1 [==============================] - 1s 530ms/step - loss: 0.0807 - val_loss: 0.0815
Epoch 55/100
1/1 [==============================] - 1s 557ms/step - loss: 0.0808 - val_loss: 0.0815
Epoch 56/100
1/1 [==============================] - 1s 549ms/step - loss: 0.0808 - val_loss: 0.0814
Epoch 57/100
1/1 [==============================] - 1s 575ms/step - loss: 0.0808 - val_loss: 0.0813
Epoch 58/100
1/1 [==============================] - 1s 554ms/step - loss: 0.0807 - val_loss: 0.0812
Epoch 59/100
1/1 [==============================] - 1s 556ms/step - loss: 0.0806 - val_loss: 0.0811
Epoch 60/100
1/1 [==============================] - 1s 588ms/step - loss: 0.0805 - val_loss: 0.0810
Epoch 61/100