BinRoot / TensorFlow-Book

Accompanying source code for Machine Learning with TensorFlow. Refer to the book for step-by-step explanations.
http://www.tensorflowbook.com
MIT License
4.45k stars 1.21k forks source link

Quick comment on Chapter 10 #7

Open airman604 opened 7 years ago

airman604 commented 7 years ago

In Concept01_timeseries_data.ipynb in Chapter 10, I believe you can simplify and speed up the following code:

def split_data(data, percent_train=0.80):
    num_rows = len(data)
    train_data, test_data = [], []
    for idx, row in enumerate(data):
        if idx < num_rows * percent_train:
            train_data.append(row)
        else:
            test_data.append(row)
    return train_data, test_data

as follows:

def split_data(data, percent_train=0.80):
    num_rows = len(data)*percent_train
    return data[:num_rows], data[num_rows:]
kureta commented 7 years ago

I didn't want to open an issue for this and it is related to Chapter 10. Can you please add an example that uses batch_sequences_with_states method?