MCPcopy Index your code
hub / github.com/lazyprogrammer/machine_learning_examples / mlp

Function mlp

tf2.0/rl_trader.py:92–111  ·  view source on GitHub ↗

A multi-layer perceptron

(input_dim, n_action, n_hidden_layers=1, hidden_dim=32)

Source from the content-addressed store, hash-verified

90
91
92def mlp(input_dim, n_action, n_hidden_layers=1, hidden_dim=32):
93 """ A multi-layer perceptron """
94
95 # input layer
96 i = Input(shape=(input_dim,))
97 x = i
98
99 # hidden layers
100 for _ in range(n_hidden_layers):
101 x = Dense(hidden_dim, activation='relu')(x)
102
103 # final layer
104 x = Dense(n_action)(x)
105
106 # make the model
107 model = Model(i, x)
108
109 model.compile(loss='mse', optimizer='adam')
110 print((model.summary()))
111 return model
112
113
114

Callers 1

__init__Method · 0.70

Calls 1

ModelClass · 0.50

Tested by

no test coverage detected