Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# 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
You can’t perform that action at this time.