Skip to content

Instantly share code, notes, and snippets.

@grantwwoodford
Created March 19, 2017 23:59
Show Gist options
  • Save grantwwoodford/8995ed040e68fc1a633d7b17142845a6 to your computer and use it in GitHub Desktop.
Save grantwwoodford/8995ed040e68fc1a633d7b17142845a6 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 thread
def t_thread():
# 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))
# calling - works
t_thread()
# versus thread - does not work
thread.start_new_thread(t_thread,())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment