Thursday 12 September 2019

Another "ValueError: Cannot feed value of shape (30, 5) for Tensor 'Placeholder:0', which has shape '(?, 30)'"

Be kind, I'm new to TensorFlow. I have found a project that trains a Policy Gradient agent to trade the stock market, trained on only the daily Close prices. And I'm interested in making it train on the Open, High, Low, and Volume features as well, so I'm attempting to add them in to the existing code. I've stripped away most of the project to leave only what's necessary for diagnosis.

You can find my Colab notebook here. And I have done my best to comment each section to make it easier to browse, and where I THINK the issues are, but I need someone to show me where and why.

I'm currently getting the error:

ValueError: Cannot feed value of shape (30, 5) for Tensor 'Placeholder:0', which has shape '(?, 30)'

...which makes sense because the self.X = tf.compat.v1.placeholder(tf.float32, (None, self.state_size)) is designed for the only feature (Close), but I'm trying to add in the other features into the state as well. The state_size is the window_size of 30 (to look back 30 rows during training). And I'm trying to change the state to include the added features. So I try to change the placeholder to self.state_size,5, but then I get the error:

ValueError: Cannot feed value of shape (35760, 5) for Tensor 'Placeholder:0', which has shape '(30, 5)'

...which I'm a little unclear about, but I don't think that's the issue. I know I'm trying to feed the tensor data in a shape that it's not expecting, but I don't know how to adapt this on my own. (I think) What I'm looking to do is add in those extra features into the get_state function so that each row is 1 window_size, and each column represents the features. Then the training should take place over the iterations.

I've found similar questions/answers at the below links to help someone who knows more about this than me out. Most of them talk about reshaping the data at the placeholder, which I thought I had tried, but now I've just outrun my knowledge. Thanks in advance.

Here

Here

Here

Here



from Another "ValueError: Cannot feed value of shape (30, 5) for Tensor 'Placeholder:0', which has shape '(?, 30)'"

No comments:

Post a Comment