-
Notifications
You must be signed in to change notification settings - Fork 0
/
neural_network.py
31 lines (23 loc) · 1 KB
/
neural_network.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from tensorflow.keras import layers, losses, optimizers, activations, metrics, regularizers
from tensorflow.keras.models import Sequential
def inverse_planning_model(height, width, output_len):
"""
Create a Keras model for inverse planning
:return: Keras model
:rtype: Keras model
"""
activation_func = activations.tanh
lambda_l2 = 0.00
model = Sequential()
# 1
model.add(layers.Dense(units=168, kernel_regularizer=regularizers.l2(lambda_l2), activation=activation_func,
input_shape=(height, width)))
# 2
model.add(layers.Dense(units=84, activation=activation_func, kernel_regularizer=regularizers.l2(lambda_l2)))
# 3
model.add(layers.Dense(units=84, activation=activation_func, kernel_regularizer=regularizers.l2(lambda_l2)))
model.add(layers.Flatten())
# 4
model.add(layers.Dense(units=output_len, activation=activations.softmax,
kernel_regularizer=regularizers.l2(lambda_l2)))
return model