MCPcopy Index your code
hub / github.com/rushter/MLAlgorithms / addition_problem

Function addition_problem

examples/nnet_rnn_binary_add.py:56–72  ·  view source on GitHub ↗
(ReccurentLayer)

Source from the content-addressed store, hash-verified

54
55
56def addition_problem(ReccurentLayer):
57 X_train, X_test, y_train, y_test = addition_dataset(8, 5000)
58
59 print(X_train.shape, X_test.shape)
60 model = NeuralNet(
61 layers=[ReccurentLayer, TimeDistributedDense(1), Activation("sigmoid")],
62 loss="mse",
63 optimizer=Adam(),
64 metric="mse",
65 batch_size=64,
66 max_epochs=15,
67 )
68 model.fit(X_train, y_train)
69 predictions = np.round(model.predict(X_test))
70 predictions = np.packbits(predictions.astype(np.uint8))
71 y_test = np.packbits(y_test.astype(np.int))
72 print(accuracy(y_test, predictions))
73
74
75# RNN

Callers 1

Calls 8

fitMethod · 0.95
NeuralNetClass · 0.90
ActivationClass · 0.90
AdamClass · 0.90
accuracyFunction · 0.90
addition_datasetFunction · 0.85
predictMethod · 0.45

Tested by

no test coverage detected