Last active
August 13, 2019 13:59
-
-
Save kirill-fedyanin/49700ee69c78eabd5af1d6a818fb7ef6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import keras | |
import numpy as np | |
model = keras.Sequential() | |
model.add(keras.layers.Dense(5, activation='sigmoid', input_shape=(1,))) | |
model.add(keras.layers.Dense(1, activation='sigmoid')) | |
model.compile('adadelta', 'mse', metrics=['accuracy']) | |
xs = np.array(range(1, 10)) | |
ys = np.array([[0] for _ in range(5)] + [[1] for _ in range(4)]) | |
model.fit(xs, ys, epochs=2000) | |
print(model.predict(xs)) | |
# 9/9 [==============================] - 0s 82us/step - loss: 0.0155 - acc: 1.0000 | |
# [[0.00141504] | |
# [0.00251564] | |
# [0.00749135] | |
# [0.0397768 ] | |
# [0.26316088] | |
# [0.74775267] | |
# [0.9371815 ] | |
# [0.9762724 ] | |
# [0.986349 ]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment