Skip to content

Instantly share code, notes, and snippets.

@grantwwoodford
Created March 20, 2017 18:41
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grantwwoodford/2f0b20f1e73aaf5e9b83f49415f3601a to your computer and use it in GitHub Desktop.
Save grantwwoodford/2f0b20f1e73aaf5e9b83f49415f3601a to your computer and use it in GitHub Desktop.
# Create first network with Keras
from keras.models import Sequential
from keras.layers import Dense
import numpy
import threading as t
import tensorflow as tf
graph = tf.get_default_graph()
def t_thread():
with graph.as_default():
# create model
model = Sequential()
model.add(Dense(12, input_dim=8, init='uniform', activation='relu'))
model.add(Dense(8, init='uniform', activation='relu'))
model.add(Dense(1, init='uniform', activation='sigmoid'))
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
# evaluate the model
scores = model.evaluate(numpy.array([[0,0,0,0,0,0,0,0]]), numpy.array([[1]]))
print("%s: %.2f%%" % (model.metrics_names[1], scores[1]*100))
th = t.Thread(target=t_thread)
th.start()
th.join()
th2 = t.Thread(target=t_thread)
th2.start()
th2.join()
th3 = t.Thread(target=t_thread)
th3.start()
th3.join()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment