Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import plaidml.keras
- plaidml.keras.install_backend()
- import math
- import numpy as np
- from keras.models import Sequential
- from keras.layers import Dense
- batch_size = 1024
- def genxy():
- pi2 = math.pi * 2
- while True:
- x = np.random.rand(batch_size)
- y = np.sin(x * pi2)
- yield (x, y)
- model = Sequential()
- model.add(Dense(2, activation='relu', input_shape=(1, )))
- model.add(Dense(4, activation='relu'))
- model.add(Dense(8, activation='relu'))
- model.add(Dense(16, activation='relu'))
- model.add(Dense(32, activation='relu'))
- model.add(Dense(1, name='output'))
- model.compile(loss='mean_squared_error', optimizer='nadam')
- model.fit_generator(
- genxy(),
- 1024,
- 4,
- verbose=2,
- validation_data=genxy(),
- validation_steps=1,
- )
Add Comment
Please, Sign In to add comment