Skip to content

Instantly share code, notes, and snippets.

View zaidalyafeai's full-sized avatar
:octocat:
Working from home

Zaid Alyafeai zaidalyafeai

:octocat:
Working from home
View GitHub Profile
model.save('saved_model/keras.h5')
print(model.predict_proba(X))
model.fit(X, y, batch_size=1, nb_epoch=1000, verbose= 0)
model = Sequential()
model.add(Dense(8, input_dim=2))
model.add(Activation('tanh'))
model.add(Dense(1))
model.add(Activation('sigmoid'))
sgd = SGD(lr=0.1)
model.compile(loss='binary_crossentropy', optimizer=sgd)
X = np.array([[0,0],[0,1],[1,0],[1,1]])
y = np.array([[0],[1],[1],[0]])
from keras.models import Sequential
from keras.layers.core import Dense, Dropout, Activation
from keras.optimizers import SGD
import numpy as np
import os
import glob
import numpy as np
from tensorflow.keras import layers
from tensorflow import keras
import tensorflow as tf
//the minimum boudning box around the current drawing
const mbb = getMinBox()
//cacluate the dpi of the current window
const dpi = window.devicePixelRatio
//extract the image data
const imgData = canvas.contextContainer.getImageData(mbb.min.x * dpi, mbb.min.y * dpi,
(mbb.max.x - mbb.min.x) * dpi, (mbb.max.y - mbb.min.y) * dpi);
const pred = model.predict(preprocess(imgData)).dataSync()
model.save('keras.h5')