Created
April 22, 2019 19:59
-
-
Save keithmgould/9f1cb7c738caa7b1f7d869c2526c670e to your computer and use it in GitHub Desktop.
failing code snippet for multiple models
This file contains 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
import numpy as np | |
from keras.models import Sequential | |
from keras.callbacks import TensorBoard | |
from keras.layers import * | |
from keras.optimizers import * | |
N=10 | |
INPUT_LEN = 4 | |
OUTPUT_LEN = 2 | |
def make_model(model): | |
model.add(Dense(units=8, activation='relu', input_dim=INPUT_LEN)) | |
model.add(Dense(units=OUTPUT_LEN, activation='linear')) | |
model.compile(loss='categorical_crossentropy', optimizer='adam') | |
model1 = Sequential() | |
model2 = Sequential() | |
make_model(model1) | |
make_model(model2) | |
print(model1.summary()) | |
print(model2.summary()) | |
x = np.random.rand(N, INPUT_LEN) | |
y = np.random.randint(0,5, size=(N,OUTPUT_LEN)) | |
print("x shape: {}".format(x.shape)) | |
print("y shape: {}".format(y.shape)) | |
model1.fit(x, y, callbacks=[TensorBoard(log_dir='./tmp', histogram_freq=1)], epochs=10, validation_data=(x,y)) | |
model2.fit(x, y, callbacks=[TensorBoard(log_dir='./tmp', histogram_freq=1)], epochs=10, validation_data=(x,y)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment