<jupyter_start><jupyter_text>YouTube Link: https://youtu.be/MGIOpoyo4cE<jupyter_code>from keras.models import Sequential
from keras.layers import Dense,Activation
import numpy as np
np.random.seed(7)
model = Sequential()
model.add(Dense(1, input_dim=3,activation='sigmoid'))
#wow, it sure is easy to add another layer.
# model.add(Dense(4,activation='relu'))
# model.add(Dense(1, activation='sigmoid'))
model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'])
# input dataset
X = np.array([[0,0,1],
              [0,1,1],
              [1,0,1],
              [1,1,1]])
# labels
#hard
#y = np.array([[0,1,1,0]]).T
#easy
y = np.array([[0,0,1,1]]).T
y
model.fit(X,y,batch_size=1,epochs=800)
results=model.predict(np.array([[0,1,0]]), verbose=1)
print(results)
print(np.round(results,0))
#print?<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.19267139479905437, 'fraction_numerical': 0.041371158392434985, 'mean_word_length': 5.669291338582677, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '522499', 'license': 'MIT', 'n_tokens_mistral': 351, 'n_tokens_neox': 345, 'n_words': 55, 'path': 'lecture_materials/2018-10-08 Build a Model with Keras/toy with keras-hidden layer.ipynb', 'repo_name': 'BethShearon/tds', 'size': '846'}