Skip to content

Commit 92792eb

Browse files
print short
1 parent 455360f commit 92792eb

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

docs/literate/tutorials/example_synthetic_lstm.jl

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ df = load_timeseries_netcdf("https://github.com/bask0/q10hybrid/raw/master/data/
2727

2828
# Select a subset of data for faster execution
2929
df = df[1:20000, :];
30-
first(df, 5)
30+
first(df, 5);
3131

3232
# ## 3. Define Neural Network Architectures
3333

@@ -105,41 +105,41 @@ hlstm = constructHybridModel(
105105
# In practice, you can skip to Section 9 and use the `train` function directly.
106106

107107
# :KeyedArray and :DimArray are supported
108-
x, y = prepare_data(hlstm, df, array_type = :DimArray)
108+
x, y = prepare_data(hlstm, df, array_type = :DimArray);
109109

110110
# New split_into_sequences with input_window, output_window, shift and lead_time
111111
# for many-to-one, many-to-many, and different prediction lead times and overlap
112-
xs, ys = split_into_sequences(x, y; input_window = 20, output_window = 2, shift = 1, lead_time = 0)
113-
ys_nan = .!isnan.(ys)
112+
xs, ys = split_into_sequences(x, y; input_window = 20, output_window = 2, shift = 1, lead_time = 0);
113+
ys_nan = .!isnan.(ys);
114114

115115
# Split data as in train
116-
sdf = split_data(df, hlstm, sequence_kwargs = (; input_window = 10, output_window = 3, shift = 1, lead_time = 1))
116+
sdf = split_data(df, hlstm, sequence_kwargs = (; input_window = 10, output_window = 3, shift = 1, lead_time = 1));
117117

118-
typeof(sdf)
119-
(x_train, y_train), (x_val, y_val) = sdf
120-
x_train
121-
y_train
122-
y_train_nan = .!isnan.(y_train)
118+
typeof(sdf);
119+
(x_train, y_train), (x_val, y_val) = sdf;
120+
x_train;
121+
y_train;
122+
y_train_nan = .!isnan.(y_train);
123123

124124
# Put into train loader to compose minibatches
125-
train_dl = EasyHybrid.DataLoader((x_train, y_train); batchsize = 32)
125+
train_dl = EasyHybrid.DataLoader((x_train, y_train); batchsize = 32);
126126

127127
# Run hybrid model forwards
128-
x_first = first(train_dl)[1]
129-
y_first = first(train_dl)[2]
128+
x_first = first(train_dl)[1];
129+
y_first = first(train_dl)[2];
130130

131-
ps, st = Lux.setup(Random.default_rng(), hlstm)
132-
frun = hlstm(x_first, ps, st)
131+
ps, st = Lux.setup(Random.default_rng(), hlstm);
132+
frun = hlstm(x_first, ps, st);
133133

134134
# Extract predicted yhat
135-
reco_mod = frun[1].reco
135+
reco_mod = frun[1].reco;
136136

137137
# Bring observations in same shape
138-
reco_obs = dropdims(y_first, dims = 1)
139-
reco_nan = .!isnan.(reco_obs)
138+
reco_obs = dropdims(y_first, dims = 1);
139+
reco_nan = .!isnan.(reco_obs);
140140

141141
# Compute loss
142-
EasyHybrid.compute_loss(hlstm, ps, st, (x_train, (y_train, y_train_nan)), logging = LoggingLoss(train_mode = true))
142+
EasyHybrid.compute_loss(hlstm, ps, st, (x_train, (y_train, y_train_nan)), logging = LoggingLoss(train_mode = true));
143143

144144
# ## 9. Train LSTM Hybrid Model
145145

@@ -157,7 +157,7 @@ out_lstm = train(
157157
sequence_kwargs = (; input_window = 10, output_window = 4),
158158
plotting = false,
159159
array_type = :DimArray
160-
)
160+
);
161161

162162
# ## 10. Train Single NN Hybrid Model (Optional)
163163

@@ -188,4 +188,4 @@ single_nn_out = train(
188188
shuffleobs = false,
189189
loss_types = [:mse, :nse],
190190
array_type = :DimArray
191-
)
191+
);

0 commit comments

Comments
 (0)