A multi-layer perceptron
(input_dim, n_action, n_hidden_layers=1, hidden_dim=32)
| 82 | |
| 83 | |
| 84 | def mlp(input_dim, n_action, n_hidden_layers=1, hidden_dim=32): |
| 85 | """ A multi-layer perceptron """ |
| 86 | |
| 87 | model = MLPRegressor( |
| 88 | hidden_layer_sizes=n_hidden_layers * [hidden_dim], |
| 89 | ) |
| 90 | |
| 91 | # since we'll be first using this to make a prediction with random weights |
| 92 | # we need to know the output size |
| 93 | |
| 94 | # so we'll just start by fitting on some dummy data |
| 95 | X = np.random.randn(100, input_dim) |
| 96 | Y = np.random.randn(100, n_action) |
| 97 | model.partial_fit(X, Y) |
| 98 | |
| 99 | return model |
| 100 | |
| 101 | |
| 102 |