-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunction_approximator.py
31 lines (25 loc) · 1 KB
/
function_approximator.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 keras import Sequential, Model, Input
from keras.layers import Dense, Conv2D
import numpy as np
class FunctionApproximator():
def __init__(self) -> None:
input = Input(shape=(12)) # (wt, wr, at, ar, adt, bt, br, bdt, action1, action2, action3, action4)
d1 = Dense(12,activation='tanh')(input)
d2 = Dense(6,activation='tanh')(d1)
output = Dense(1,activation="linear")(d2)
self.model = Model(inputs=[input],outputs=output)
self.model.compile(optimizer='adam',loss='mse')
# test = FunctionApproximator()
# x_test:np.ndarray = np.array([[1,0,1,0,1,0,1,0,1],[1,0,1,0,1,0,1,0,1],[1,0,1,0,1,0,1,0,1],[0,0,1,1,0,0,1,1,0]])
# y_test:np.ndarray = np.array([[10],[10],[10],[-10]])
# print(x_test.shape)
# print(y_test.shape)
# test.model.fit(
# x=[x_test],
# y=y_test
# )
# xhat = np.array([[1,0,1,0,1,0,1,0,1]])
# print(test.model.predict(xhat)[0][0])
# xhat = np.array([[0,0,1,1,0,0,1,1,0]])
# print(test.model.predict(xhat)[0][0])
# WTKill -> alpha + 180 >= 2*theta