llSourcell / Financial_Forecasting_with_TensorflowJS

This is the code for "Financial Forecasting with Tensorflow.js" By Siraj Raval on Youtube
187 stars 84 forks source link

Console error expected dense_Dense1 to have shape [,57,10] #1

Open Lipe991 opened 6 years ago

Lipe991 commented 6 years ago

I've got an error trying to run your code,

Uncaught (in promise) Error: Error when checking target: expected dense_Dense1 to have shape [,57,10], but got array with shape [1,1960,1].

hallvardkristiansen commented 6 years ago

Same, I've tried changing a lot of parameters and modifying the data structure, but I can't get rid of it. The error appears in model.fit (and also when testing model.evaluate) at line 105 in 2b_cnn.js

hallvardkristiansen commented 6 years ago

I would love a thorough explanation for why this happens in this case in particular. I've been banging my head against it for a while now and the head is losing.

thzou commented 6 years ago

I implement this in Python and Js, same error with data shapes in Dense Layer.

plska commented 6 years ago

glad I'm not the only one seeing this error.

Thoughtscript commented 6 years ago

I'm afraid it's my fault - I wrote the original (and as yet uncompleted) code! The CNN wasn't fully implemented yet!

NINJA EDIT - 9.30.18: Very sorry all please see the comment added below. Also, forgive the excessive !'s. Thanks!

pabx06 commented 6 years ago

no fix ?

ashbeats commented 6 years ago

did anyone manage to figure this out...

ashbeats commented 6 years ago

There are major errors with the code. It is not in a functioning state and that makes me wonder it was even tested before the video was recorded?

Firstly, data.highs is mapped to epoch times here:

https://github.com/llSourcell/Financial_Forecasting_with_TensorflowJS/blob/3244c20286dcb020c24fc948a3c408a6bf03b705/public/scripts/2a_cnn.js#L35

then comes the reshaping part. Why not reshape it prior when the dates are being converted to epoch?

https://github.com/llSourcell/Financial_Forecasting_with_TensorflowJS/blob/3244c20286dcb020c24fc948a3c408a6bf03b705/public/scripts/2b_cnn.js#L94

That does not make sense. ( https://js.tensorflow.org/api/0.12.5/#reshape )

and then the part that left me speechless was this...

https://github.com/llSourcell/Financial_Forecasting_with_TensorflowJS/blob/3244c20286dcb020c24fc948a3c408a6bf03b705/public/scripts/2b_cnn.js#L95

Why would you map a price series that way? Not even sure what was the goal...

Could someone enlighten me. I'm not sure how the reshaped list should look like.

hallvardkristiansen commented 6 years ago

It wasn't tested, it's just an idea but that wasn't made very clear in the video. I've played around with it a lot and gotten it to a state where it works fairly well with a simple NN consisting only of dense layers. Next step is to get my head around formatting the data as matrices and implementing a CNN, but I'm learning as I'm going and some of the maths is hard.

hallvardkristiansen commented 6 years ago

http://oracle.gigil.berlin/

klosowsk commented 6 years ago

Same problems here!

craftgear commented 6 years ago

Same here, kinda disappointment.

craftgear commented 6 years ago

@llSourcell Hi, do you notice this issue?

Thoughtscript commented 6 years ago

There are major errors with the code. It is not in a functioning state and that makes me wonder it was even tested before the video was recorded?

Firstly, data.highs is mapped to epoch times here:

Financial_Forecasting_with_TensorflowJS/public/scripts/2a_cnn.js

Line 35 in 3244c20

dates.push(new Date(data[i]['Date'] + 'T00:00:00.000').getTime()) then comes the reshaping part. Why not reshape it prior when the dates are being converted to epoch?

Financial_Forecasting_with_TensorflowJS/public/scripts/2b_cnn.js

Line 94 in 3244c20

tdates.reshape([1, 1960, 1]), That does not make sense. ( https://js.tensorflow.org/api/0.12.5/#reshape )

and then the part that left me speechless was this...

Financial_Forecasting_with_TensorflowJS/public/scripts/2b_cnn.js

Line 95 in 3244c20

thighs.reshape([1, 1960, 1]), { Why would you map a price series that way? Not even sure what was the goal...

Could someone enlighten me. I'm not sure how the reshaped list should look like.

Hi All!

I'm @Thoughtscript - I wanted to apologize about the confusion this has caused! Yikes!

First, let me be very clear that I'm not in any way affiliated with @llSourcell.

This code was NOT PRODUCTION WORTHY and INCOMPLETE - as noted on the original repo listed here - it's a WORK IN PROGRESS.

Actually, I'm not sure how it ended up in a video or attracting any interest whatsoever.

The code was being completed for an article to be posted on the top-ranked consulting firm X-Team's blog. Unfortunately, the company decided to move in another direction with its writing and I've since moved over to Microsoft (though I remain affiliated with X-Team's great community).

Every other repo listed under my @Thoughtscript account without a WIP flag should be fully functional (with any issues, if they exist, noted). This particular project (which you'll note bears my name on in the pictures), is actually no longer maintained.

Any questions, feel free to send me an email at adam.gerard@gmail.com. Sorry for any confusion this has caused.

Cheers!

Thoughtscript commented 6 years ago

PS - maybe try:

  1. Normalizing the values
  2. Correcting the shapes
  3. Correctly configuring the convolutional neural net
  4. Leveraging parallel processing and WebGL since that shit's gonna break on single-threaded JS
craftgear commented 6 years ago

Hi @Thoughtscript , thanks for your kind explanation and mostly for noticing this issue!

Now the big question is, what was the working demo which @llSourcell showed us in his Live stream. https://youtu.be/5Uw1iSwvHH8?t=47m53s

Anyway, I think this is not a proper learning material after all.

max-hans commented 5 years ago

Anyway, I think this is not a proper learning material after all.

exactly - this is generating a lot of confusion. for beginners this whole subject is hard to grasp and it is made even harder with all the other backend stuff going on.

siraj makes stuff look really easy by skipping a lot of difficult and crucial steps and this repo here is the perfect example i wasn't even aware that this is not his code - but maybe i just didn't pay attention ¯_(ツ)_/¯

gognjanovski commented 5 years ago

I tried to use the code but it didn't worked for me. So the closest working solution that I got was this one: https://towardsdatascience.com/stock-price-prediction-system-using-1d-cnn-with-tensorflow-js-machine-learning-easy-and-fun-fe5323e68ffb

Hope that helps.