(ReccurentLayer)
| 54 | |
| 55 | |
| 56 | def 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 |
no test coverage detected