1. I first on the source code
The following code is written by a person lstm input data processing:
def load_data (filename, Seq_len, Normalise_window):
f = open (filename, ' RB '). Read ()
data = F.split (' \ n ')
Sequence_length = seq_len + 1 result
= [] for
index in range (LEN (data)-Sequence_length):
result.append (data [Index:index + sequence_length])
If Normalise_window: Result
= normalise_windows [result] result
= Np.array (result)
row = round (0.9 * Result.shape[0])
train = Result[:row,:
np.random.shuffle (train)
X_train = train[:,: -1]
Y_ Train = train[:,-1]
x_test = Result[row:,: -1]
y_test = Result[row:,-1]
X_train = Np.reshape (X_train, (x_ Train.shape[0], x_train.shape[1], 1)
x_test = Np.reshape (X_test, (x_test.shape[0), x_test.shape[1], 1
) return [X_train, Y_train, X_test, Y_test]
No further, take a step in the data
For example, the source data is
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
Then I agreed that the step size is 3, then the data obtained is [1,2,3], [2,3,4], ..., [13,14,15]
2. Code interpretation
X_train = train[:,:-1]
This code indicates that every row in the train is removed, but for the column, the last column is not taken
GitHub Source: Lstm_learn