Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues reproducing sine wave example #4

Closed
robotdude17 opened this issue Mar 5, 2017 · 3 comments
Closed

Issues reproducing sine wave example #4

robotdude17 opened this issue Mar 5, 2017 · 3 comments

Comments

@robotdude17
Copy link

I've tried to reproduce the sine wave example using the following code in the main function seen below.

Apparently, something went wrong, see the image I have received.

Do you know what I need to fix in order to reproduce your example?

Thanks!

#Main Run Thread
if name=='main':

os.system('clear')
global_start_time = time.time()
epochs  = 1
seq_len = 50

print '> Loading data... '

X_train, y_train, X_test, y_test = lstm.load_data('sinwave.csv', seq_len, True)

print '> Data Loaded. Compiling...'

model = lstm.build_model([1, 50, 100, 1])

model.fit(
    X_train,
    y_train,
    batch_size=512,
    nb_epoch=epochs,
    validation_split=0.05)

predicted = lstm.predict_point_by_point(model, X_test)        

print 'Training duration (s) : ', time.time() - global_start_time
plot_results(predicted, y_train)

prediction_sine_wave_01

@jaungiers
Copy link
Owner

For starters it seems you've got an issue loading the actual sin wave data... The true data should be a high-frequency sin wave over the time period... Not a constant of -2.0... Please review your ETL procedures and data file.

@simonholgate
Copy link

I had a similar problem. I traced it to the importing of the sin wave data which is all quoted strings (at least on OS X High Sierra and Python 3.6.3). Converting the data after reading and decoding data = f.decode().split('\n') with:
data = list(map(float, data)) (which converts all the data to floats) to seems to do the trick.

@markjay4k
Copy link

markjay4k commented Jan 19, 2018

@robotdude17 With seq_len = 50, and normalise_window = True, both y_train and y_test will have all entries equal to -2.

I would suggest not normalizing the window, i.e. normalise_window = False

basically use this line in your code above instead

X_train, y_train, X_test, y_test = lstm.load_data('sinwave.csv', seq_len, False)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants