I tried to build an simple trading bot. I use deep q-learning to do that. The boot get as input an single array of stock prices.
input = [9540.5 9167. 8651.8 9200.5 8780.]
This is how my model looks like.
model = Sequential()
model.add(Dense(units=64, input_dim = 1, activation="relu"))
model.add(Dense(32))
model.add(Dense(16))
model.add(Dense(8))
model.add(Dense(self.action_size, activation="linear"))
model.compile(loss="mse", optimizer=Adam(lr=0.001))
start = time.time()
model.summary()
return model
This is what I will get
desire Output: [ 70.84186 -218.39314 -1069.3423 ]
and this is how it looks like:
actual output:
[
[ 70.84186 -218.39314 -1069.3423 ]
[ 70.84186 -218.39314 -1069.3423 ]
[ 70.84186 -218.39314 -1069.3423 ]
[ 70.84186 -218.39314 -1069.3423 ]
[ 70.84186 -218.39314 -1069.3423 ]
]
Can please someone tell me how to reduce the dimension of the output.
After try and error, i found out that, my input was wrong.
input = [1,2,3,4]
was interpret from the Network, as 4 examples, not as one example with 4 features. So i have used the Numpy to change my input.
input = np.array(input)
input = np.expand_dims(input, axis=0)
So after that the input looks like this:
[[1,2,3,4]]
With this input network calculated only one output.
ps. Matias Valdenergo The input was an time series of changing stock prices. The output was the weighted value of certain action, as hold, sell or buy.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.