Created
August 30, 2017 07:10
-
-
Save pbloem/4f899053c9815e27425d34d20623afa7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
import numpy as np | |
from keras import Input | |
import keras.backend as K | |
from keras.callbacks import TensorBoard | |
from keras.engine import Model | |
from keras.layers import LSTM, TimeDistributed, Dense, Reshape, Flatten, LeakyReLU, Lambda | |
from keras.optimizers import Adam, sgd | |
BATCH_SIZE = 512 | |
TRAIN_VALIDATE_SPLIT = 0.1 | |
EPOCHS = 50 | |
OPTIMIZER = Adam(lr=0.01) | |
data = np.random.rand(50000, 2, 2) | |
target = np.sqrt( | |
np.square(data[:, 0, 0] - data[0:, 1, 0]) + # delta rd_x | |
np.square(data[:, 0, 1] - data[0:, 1, 1])) # delta rd_y | |
input = Input(name='Input', shape=(2, 2)) | |
x = Flatten()(input) | |
x = Dense(16, activation='relu')(x) | |
x = Dense(1)(x) | |
model = Model(input, x) | |
model.compile(loss='mse', optimizer=OPTIMIZER) | |
model.summary() | |
history = model.fit(x=data, | |
y=target, | |
epochs=EPOCHS, | |
batch_size=BATCH_SIZE, | |
validation_split=TRAIN_VALIDATE_SPLIT).history | |
# print(history) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment