Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import h5py
- import numpy as np
- import tensorflow as tf
- import matplotlib.pyplot as plt
- import math as math
- import scipy
- f = h5py.File('/Users/Krzysztof/PycharmProjects/untitled/venv/4studs.hdf5', 'r')
- keys = list(f.keys())
- def wejscie(k): #zwraca (1, 32, 6250, 1)
- x = f.get(keys[k])
- x1 = tf.slice(x,[0,0],[32,6250])
- x2 = tf.reshape(x1,[1,32,6250,1])
- x3 = tf.keras.utils.normalize(x2)
- return x3
- def wyjscie(k): #zwraca (1, 1, 1, 6211)
- x = f.get(keys[180+k])
- x1 = tf.slice(x,[0],[6211])
- x2 = tf.reshape(x1,[1,1,1,6211])
- return x2
- #MODEL
- model = tf.keras.Sequential([
- tf.keras.layers.Conv2D(64, kernel_size=(32,40),padding='valid',input_shape=(32,6250,1)),
- tf.keras.layers.Dense(32,activation='tanh'),
- tf.keras.layers.Dense(1,activation='linear')
- ])
- model.compile(optimizer='nadam',loss='mse',metrics=['accuracy'])
- for n in range(1):
- model.fit(wejscie(n),wyjscie(n),epochs=3)
- pred = model.predict(wejscie(179))
- print(pred.shape)
- pred1 = tf.reshape(pred,[-1,1,6211])
- pred2 = tf.reshape(pred1,[-1,6211])
- pred3 = tf.reshape(pred2,[6211])
- plt.figure()
- plt.plot(pred3)
- plt.plot(f.get(keys[359]))
- plt.show()
- f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement