dragon-ml-toolbox 6.4.1__py3-none-any.whl → 8.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of dragon-ml-toolbox might be problematic. Click here for more details.

ml_tools/ML_models.py CHANGED
@@ -1,45 +1,35 @@
1
1
  import torch
2
2
  from torch import nn
3
- from ._script_info import _script_info
4
- from typing import List, Union
3
+ from typing import List, Union, Tuple, Dict, Any
5
4
  from pathlib import Path
6
5
  import json
7
6
  from ._logger import _LOGGER
8
7
  from .path_manager import make_fullpath
9
-
8
+ from ._script_info import _script_info
10
9
 
11
10
  __all__ = [
12
11
  "MultilayerPerceptron",
12
+ "AttentionMLP",
13
+ "MultiHeadAttentionMLP",
14
+ "TabularTransformer",
13
15
  "SequencePredictorLSTM",
14
16
  "save_architecture",
15
17
  "load_architecture"
16
18
  ]
17
19
 
18
20
 
19
- class MultilayerPerceptron(nn.Module):
21
+ class _BaseMLP(nn.Module):
20
22
  """
21
- Creates a versatile Multilayer Perceptron (MLP) for regression or classification tasks.
22
-
23
- This model generates raw output values (logits) suitable for use with loss
24
- functions like `nn.CrossEntropyLoss` (for classification) or `nn.MSELoss`
25
- (for regression).
26
-
27
- Args:
28
- in_features (int): The number of input features (e.g., columns in your data).
29
- out_targets (int): The number of output targets. For regression, this is
30
- typically 1. For classification, it's the number of classes.
31
- hidden_layers (list[int]): A list where each integer represents the
32
- number of neurons in a hidden layer. Defaults to [40, 80, 40].
33
- drop_out (float): The dropout probability for neurons in each hidden
34
- layer. Must be between 0.0 and 1.0. Defaults to 0.2.
35
-
36
- ### Rules of thumb:
37
- - Choose a number of hidden neurons between the size of the input layer and the size of the output layer.
38
- - The number of hidden neurons should be 2/3 the size of the input layer, plus the size of the output layer.
39
- - The number of hidden neurons should be less than twice the size of the input layer.
23
+ A base class for Multilayer Perceptrons.
24
+
25
+ Handles validation, configuration, and the creation of the core MLP layers,
26
+ allowing subclasses to define their own pre-processing and forward pass.
40
27
  """
41
- def __init__(self, in_features: int, out_targets: int,
42
- hidden_layers: List[int] = [40, 80, 40], drop_out: float = 0.2) -> None:
28
+ def __init__(self,
29
+ in_features: int,
30
+ out_targets: int,
31
+ hidden_layers: List[int],
32
+ drop_out: float) -> None:
43
33
  super().__init__()
44
34
 
45
35
  # --- Validation ---
@@ -58,50 +48,481 @@ class MultilayerPerceptron(nn.Module):
58
48
  self.hidden_layers = hidden_layers
59
49
  self.drop_out = drop_out
60
50
 
61
- # --- Build network layers ---
62
- layers = []
51
+ # --- Build the core MLP network ---
52
+ mlp_layers = []
63
53
  current_features = in_features
64
54
  for neurons in hidden_layers:
65
- layers.extend([
55
+ mlp_layers.extend([
66
56
  nn.Linear(current_features, neurons),
67
57
  nn.BatchNorm1d(neurons),
68
58
  nn.ReLU(),
69
59
  nn.Dropout(p=drop_out)
70
60
  ])
71
61
  current_features = neurons
62
+
63
+ self.mlp = nn.Sequential(*mlp_layers)
64
+ # Set a customizable Prediction Head for flexibility, specially in transfer learning and fine-tuning
65
+ self.output_layer = nn.Linear(current_features, out_targets)
72
66
 
73
- # Add the final output layer
74
- layers.append(nn.Linear(current_features, out_targets))
75
-
76
- self._layers = nn.Sequential(*layers)
77
-
78
- def forward(self, x: torch.Tensor) -> torch.Tensor:
79
- """Defines the forward pass of the model."""
80
- return self._layers(x)
81
-
82
- def get_config(self) -> dict:
83
- """Returns the configuration of the model."""
67
+ def get_config(self) -> Dict[str, Any]:
68
+ """Returns the base configuration of the model."""
84
69
  return {
85
70
  'in_features': self.in_features,
86
71
  'out_targets': self.out_targets,
87
72
  'hidden_layers': self.hidden_layers,
88
73
  'drop_out': self.drop_out
89
74
  }
75
+
76
+ def _repr_helper(self, name: str, mlp_layers: list[str]):
77
+ last_layer = self.output_layer
78
+ if isinstance(last_layer, nn.Linear):
79
+ mlp_layers.append(str(last_layer.out_features))
80
+ else:
81
+ mlp_layers.append("Custom Prediction Head")
82
+
83
+ # Creates a string like: 10 -> 40 -> 80 -> 40 -> 2
84
+ arch_str = ' -> '.join(mlp_layers)
85
+
86
+ return f"{name}(arch: {arch_str})"
87
+
88
+
89
+ class MultilayerPerceptron(_BaseMLP):
90
+ """
91
+ Creates a versatile Multilayer Perceptron (MLP) for regression or classification tasks.
92
+ """
93
+ def __init__(self, in_features: int, out_targets: int,
94
+ hidden_layers: List[int] = [256, 128], drop_out: float = 0.2) -> None:
95
+ """
96
+ Args:
97
+ in_features (int): The number of input features (e.g., columns in your data).
98
+ out_targets (int): The number of output targets. For regression, this is
99
+ typically 1. For classification, it's the number of classes.
100
+ hidden_layers (list[int]): A list where each integer represents the
101
+ number of neurons in a hidden layer.
102
+ drop_out (float): The dropout probability for neurons in each hidden
103
+ layer. Must be between 0.0 and 1.0.
104
+
105
+ ### Rules of thumb:
106
+ - Choose a number of hidden neurons between the size of the input layer and the size of the output layer.
107
+ - The number of hidden neurons should be 2/3 the size of the input layer, plus the size of the output layer.
108
+ - The number of hidden neurons should be less than twice the size of the input layer.
109
+ """
110
+ super().__init__(in_features, out_targets, hidden_layers, drop_out)
111
+
112
+ def forward(self, x: torch.Tensor) -> torch.Tensor:
113
+ """Defines the forward pass of the model."""
114
+ x = self.mlp(x)
115
+ logits = self.output_layer(x)
116
+ return logits
90
117
 
91
118
  def __repr__(self) -> str:
92
119
  """Returns the developer-friendly string representation of the model."""
93
120
  # Extracts the number of neurons from each nn.Linear layer
94
- layer_sizes = [layer.in_features for layer in self._layers if isinstance(layer, nn.Linear)]
121
+ layer_sizes = [str(layer.in_features) for layer in self.mlp if isinstance(layer, nn.Linear)]
95
122
 
96
- # Get the last layer and check its type before accessing the attribute
97
- last_layer = self._layers[-1]
98
- if isinstance(last_layer, nn.Linear):
99
- layer_sizes.append(last_layer.out_features)
123
+ return self._repr_helper(name="MultilayerPerceptron", mlp_layers=layer_sizes)
124
+
125
+
126
+ class AttentionMLP(_BaseMLP):
127
+ """
128
+ A Multilayer Perceptron (MLP) that incorporates an Attention layer to dynamically weigh input features.
129
+
130
+ In inference mode use `forward_attention()` to get a tuple with `(output, attention_weights)`
131
+ """
132
+ def __init__(self, in_features: int, out_targets: int,
133
+ hidden_layers: List[int] = [256, 128], drop_out: float = 0.2) -> None:
134
+ """
135
+ Args:
136
+ in_features (int): The number of input features (e.g., columns in your data).
137
+ out_targets (int): The number of output targets. For regression, this is
138
+ typically 1. For classification, it's the number of classes.
139
+ hidden_layers (list[int]): A list where each integer represents the
140
+ number of neurons in a hidden layer.
141
+ drop_out (float): The dropout probability for neurons in each hidden
142
+ layer. Must be between 0.0 and 1.0.
143
+ """
144
+ super().__init__(in_features, out_targets, hidden_layers, drop_out)
145
+ # Attention
146
+ self.attention = _AttentionLayer(in_features)
147
+
148
+ def forward(self, x: torch.Tensor) -> torch.Tensor:
149
+ """
150
+ Defines the standard forward pass.
151
+ """
152
+ logits, _attention_weights = self.forward_attention(x)
153
+ return logits
154
+
155
+ def forward_attention(self, x: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor]:
156
+ """
157
+ Returns logits and attention weights
158
+ """
159
+ # The attention layer returns the processed x and the weights
160
+ x, attention_weights = self.attention(x)
100
161
 
101
- # Creates a string like: 10 -> 40 -> 80 -> 40 -> 2
102
- arch_str = ' -> '.join(map(str, layer_sizes))
162
+ # Pass the attention-modified tensor through the MLP
163
+ logits = self.mlp(x)
164
+
165
+ return logits, attention_weights
166
+
167
+ def __repr__(self) -> str:
168
+ """Returns the developer-friendly string representation of the model."""
169
+ # Start with the input features and the attention marker
170
+ arch = [str(self.in_features), "[Attention]"]
171
+
172
+ # Find all other linear layers in the MLP
173
+ for layer in self.mlp[1:]:
174
+ if isinstance(layer, nn.Linear):
175
+ arch.append(str(layer.in_features))
103
176
 
104
- return f"MultilayerPerceptron(arch: {arch_str})"
177
+ return self._repr_helper(name="AttentionMLP", mlp_layers=arch)
178
+
179
+
180
+ class MultiHeadAttentionMLP(_BaseMLP):
181
+ """
182
+ An MLP that incorporates a standard `nn.MultiheadAttention` layer to process
183
+ the input features.
184
+
185
+ In inference mode use `forward_attention()` to get a tuple with `(output, attention_weights)`.
186
+ """
187
+ def __init__(self, in_features: int, out_targets: int,
188
+ hidden_layers: List[int] = [256, 128], drop_out: float = 0.2,
189
+ num_heads: int = 4, attention_dropout: float = 0.1) -> None:
190
+ """
191
+ Args:
192
+ in_features (int): The number of input features.
193
+ out_targets (int): The number of output targets.
194
+ hidden_layers (list[int]): A list of neuron counts for each hidden layer.
195
+ drop_out (float): The dropout probability for the MLP layers.
196
+ num_heads (int): The number of attention heads.
197
+ attention_dropout (float): Dropout probability in the attention layer.
198
+ """
199
+ super().__init__(in_features, out_targets, hidden_layers, drop_out)
200
+ self.num_heads = num_heads
201
+ self.attention_dropout = attention_dropout
202
+
203
+ self.attention = _MultiHeadAttentionLayer(
204
+ num_features=in_features,
205
+ num_heads=num_heads,
206
+ dropout=attention_dropout
207
+ )
208
+
209
+ def forward(self, x: torch.Tensor) -> torch.Tensor:
210
+ """Defines the standard forward pass of the model."""
211
+ logits, _attention_weights = self.forward_attention(x)
212
+ return logits
213
+
214
+ def forward_attention(self, x: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor]:
215
+ """
216
+ Returns logits and attention weights.
217
+ """
218
+ # The attention layer returns the processed x and the weights
219
+ x, attention_weights = self.attention(x)
220
+
221
+ # Pass the attention-modified tensor through the MLP and prediction head
222
+ x = self.mlp(x)
223
+ logits = self.output_layer(x)
224
+
225
+ return logits, attention_weights
226
+
227
+ def get_config(self) -> Dict[str, Any]:
228
+ """Returns the full configuration of the model."""
229
+ config = super().get_config()
230
+ config['num_heads'] = self.num_heads
231
+ config['attention_dropout'] = self.attention_dropout
232
+ return config
233
+
234
+ def __repr__(self) -> str:
235
+ """Returns the developer-friendly string representation of the model."""
236
+ mlp_part = " -> ".join(
237
+ [str(self.in_features)] +
238
+ [str(h) for h in self.hidden_layers] +
239
+ [str(self.out_targets)]
240
+ )
241
+ arch_str = f"{self.in_features} -> [MultiHead(h={self.num_heads})] -> {mlp_part}"
242
+
243
+ return f"MultiHeadAttentionMLP(arch: {arch_str})"
244
+
245
+
246
+ class TabularTransformer(nn.Module):
247
+ """
248
+ A Transformer-based model for tabular data tasks.
249
+
250
+ This model uses a Feature Tokenizer to convert all input features into a sequence of embeddings, prepends a [CLS] token, and processes the
251
+ sequence with a standard Transformer Encoder.
252
+ """
253
+ def __init__(self, *,
254
+ out_targets: int,
255
+ numerical_indices: List[int],
256
+ categorical_map: Dict[int, int],
257
+ embedding_dim: int = 32,
258
+ num_heads: int = 8,
259
+ num_layers: int = 6,
260
+ dropout: float = 0.1):
261
+ """
262
+ Args:
263
+ out_targets (int): Number of output targets (1 for regression).
264
+ numerical_indices (List[int]): Column indices for numerical features.
265
+ categorical_map (Dict[int, int]): Maps categorical column index to its cardinality (number of unique categories).
266
+ embedding_dim (int): The dimension for all feature embeddings. Must be divisible by num_heads.
267
+ num_heads (int): The number of heads in the multi-head attention mechanism.
268
+ num_layers (int): The number of sub-encoder-layers in the transformer encoder.
269
+ dropout (float): The dropout value.
270
+
271
+ Note:
272
+ - All arguments are keyword-only to promote clarity.
273
+ - Column indices start at 0.
274
+
275
+ ### Data Preparation
276
+ The model requires a specific input format. All columns in the input DataFrame must be numerical, but they are treated differently based on the
277
+ provided index lists.
278
+
279
+ **Nominal Categorical Features** (e.g., 'City', 'Color'): Should **NOT** be one-hot encoded.
280
+ Instead, convert them to integer codes (label encoding). You must then provide a dictionary mapping their column indices to
281
+ their cardinality (the number of unique categories) via the `categorical_map` parameter.
282
+
283
+ **Ordinal & Binary Features** (e.g., 'Low/Medium/High', 'True/False'): Should be treated as **numerical**. Map them to numbers that
284
+ represent their state (e.g., `{'Low': 0, 'Medium': 1}` or `{False: 0, True: 1}`). Their column indices should be included in the
285
+ `numerical_indices` list.
286
+
287
+ **Standard Numerical Features** (e.g., 'Age', 'Price'): Should be included in the `numerical_indices` list. It is highly recommended to
288
+ scale them before training.
289
+ """
290
+ super().__init__()
291
+
292
+ # --- Save configuration ---
293
+ self.out_targets = out_targets
294
+ self.numerical_indices = numerical_indices
295
+ self.categorical_map = categorical_map
296
+ self.embedding_dim = embedding_dim
297
+ self.num_heads = num_heads
298
+ self.num_layers = num_layers
299
+ self.dropout = dropout
300
+
301
+ # --- 1. Feature Tokenizer ---
302
+ self.tokenizer = _FeatureTokenizer(
303
+ numerical_indices=numerical_indices,
304
+ categorical_map=categorical_map,
305
+ embedding_dim=embedding_dim
306
+ )
307
+
308
+ # --- 2. CLS Token ---
309
+ # A learnable token that will be prepended to the sequence.
310
+ self.cls_token = nn.Parameter(torch.randn(1, 1, embedding_dim))
311
+
312
+ # --- 3. Transformer Encoder ---
313
+ encoder_layer = nn.TransformerEncoderLayer(
314
+ d_model=embedding_dim,
315
+ nhead=num_heads,
316
+ dropout=dropout,
317
+ batch_first=True # Crucial for (batch, seq, feature) input
318
+ )
319
+ self.transformer_encoder = nn.TransformerEncoder(
320
+ encoder_layer=encoder_layer,
321
+ num_layers=num_layers
322
+ )
323
+
324
+ # --- 4. Prediction Head ---
325
+ self.output_layer = nn.Linear(embedding_dim, out_targets)
326
+
327
+ def forward(self, x: torch.Tensor) -> torch.Tensor:
328
+ """Defines the forward pass of the model."""
329
+ # Get the batch size for later use
330
+ batch_size = x.shape[0]
331
+
332
+ # 1. Get feature tokens from the tokenizer
333
+ # -> tokens shape: (batch_size, num_features, embedding_dim)
334
+ tokens = self.tokenizer(x)
335
+
336
+ # 2. Prepend the [CLS] token to the sequence
337
+ # -> cls_tokens shape: (batch_size, 1, embedding_dim)
338
+ cls_tokens = self.cls_token.expand(batch_size, -1, -1)
339
+ # -> full_sequence shape: (batch_size, num_features + 1, embedding_dim)
340
+ full_sequence = torch.cat([cls_tokens, tokens], dim=1)
341
+
342
+ # 3. Pass the full sequence through the Transformer Encoder
343
+ # -> transformer_out shape: (batch_size, num_features + 1, embedding_dim)
344
+ transformer_out = self.transformer_encoder(full_sequence)
345
+
346
+ # 4. Isolate the output of the [CLS] token (it's the first one)
347
+ # -> cls_output shape: (batch_size, embedding_dim)
348
+ cls_output = transformer_out[:, 0]
349
+
350
+ # 5. Pass the [CLS] token's output through the prediction head
351
+ # -> logits shape: (batch_size, out_targets)
352
+ logits = self.output_layer(cls_output)
353
+
354
+ return logits
355
+
356
+ def get_config(self) -> Dict[str, Any]:
357
+ """Returns the full configuration of the model."""
358
+ return {
359
+ 'out_targets': self.out_targets,
360
+ 'numerical_indices': self.numerical_indices,
361
+ 'categorical_map': self.categorical_map,
362
+ 'embedding_dim': self.embedding_dim,
363
+ 'num_heads': self.num_heads,
364
+ 'num_layers': self.num_layers,
365
+ 'dropout': self.dropout
366
+ }
367
+
368
+ def __repr__(self) -> str:
369
+ """Returns the developer-friendly string representation of the model."""
370
+ num_features = len(self.numerical_indices) + len(self.categorical_map)
371
+
372
+ # Build the architecture string part-by-part
373
+ parts = [
374
+ f"Tokenizer(features={num_features}, dim={self.embedding_dim})",
375
+ "[CLS]",
376
+ f"TransformerEncoder(layers={self.num_layers}, heads={self.num_heads})",
377
+ f"PredictionHead(outputs={self.out_targets})"
378
+ ]
379
+
380
+ arch_str = " -> ".join(parts)
381
+
382
+ return f"TabularTransformer(arch: {arch_str})"
383
+
384
+
385
+ class _FeatureTokenizer(nn.Module):
386
+ """
387
+ Transforms raw numerical and categorical features from any column order into a sequence of embeddings.
388
+ """
389
+ def __init__(self,
390
+ numerical_indices: List[int],
391
+ categorical_map: Dict[int, int],
392
+ embedding_dim: int):
393
+ """
394
+ Args:
395
+ numerical_indices (List[int]): A list of column indices for the numerical features.
396
+ categorical_map (Dict[int, int]): A dictionary mapping each categorical column index to its cardinality (number of unique categories).
397
+ embedding_dim (int): The dimension for all feature embeddings.
398
+ """
399
+ super().__init__()
400
+
401
+ # Unpack the dictionary into separate lists for indices and cardinalities
402
+ self.categorical_indices = list(categorical_map.keys())
403
+ cardinalities = list(categorical_map.values())
404
+
405
+ self.numerical_indices = numerical_indices
406
+ self.embedding_dim = embedding_dim
407
+
408
+ # A learnable embedding for each numerical feature
409
+ self.numerical_embeddings = nn.Parameter(torch.randn(len(numerical_indices), embedding_dim))
410
+
411
+ # A standard embedding layer for each categorical feature
412
+ self.categorical_embeddings = nn.ModuleList(
413
+ [nn.Embedding(num_embeddings=c, embedding_dim=embedding_dim) for c in cardinalities]
414
+ )
415
+
416
+ def forward(self, x: torch.Tensor) -> torch.Tensor:
417
+ """
418
+ Processes features from a single input tensor and concatenates them
419
+ into a sequence of tokens.
420
+ """
421
+ # Select the correct columns for each type using the stored indices
422
+ x_numerical = x[:, self.numerical_indices].float()
423
+ x_categorical = x[:, self.categorical_indices].long()
424
+
425
+ # Process numerical features
426
+ numerical_tokens = x_numerical.unsqueeze(-1) * self.numerical_embeddings
427
+
428
+ # Process categorical features
429
+ categorical_tokens = []
430
+ for i, embed_layer in enumerate(self.categorical_embeddings):
431
+ token = embed_layer(x_categorical[:, i]).unsqueeze(1)
432
+ categorical_tokens.append(token)
433
+
434
+ # Concatenate all tokens into a single sequence
435
+ if not self.categorical_indices:
436
+ all_tokens = numerical_tokens
437
+ elif not self.numerical_indices:
438
+ all_tokens = torch.cat(categorical_tokens, dim=1)
439
+ else:
440
+ all_categorical_tokens = torch.cat(categorical_tokens, dim=1)
441
+ all_tokens = torch.cat([numerical_tokens, all_categorical_tokens], dim=1)
442
+
443
+ return all_tokens
444
+
445
+
446
+ class _AttentionLayer(nn.Module):
447
+ """
448
+ Calculates attention weights and applies them to the input features, incorporating a residual connection for improved stability and performance.
449
+
450
+ Returns both the final output and the weights for interpretability.
451
+ """
452
+ def __init__(self, num_features: int):
453
+ super().__init__()
454
+ # The hidden layer size is a hyperparameter
455
+ hidden_size = max(16, num_features // 4)
456
+
457
+ # Learn to produce attention scores
458
+ self.attention_net = nn.Sequential(
459
+ nn.Linear(num_features, hidden_size),
460
+ nn.Tanh(),
461
+ nn.Linear(hidden_size, num_features) # Output one score per feature
462
+ )
463
+ self.softmax = nn.Softmax(dim=1)
464
+
465
+ def forward(self, x: torch.Tensor) -> tuple[torch.Tensor, torch.Tensor]:
466
+ # x shape: (batch_size, num_features)
467
+
468
+ # Get one raw "importance" score per feature
469
+ attention_scores = self.attention_net(x)
470
+
471
+ # Apply the softmax module to get weights that sum to 1
472
+ attention_weights = self.softmax(attention_scores)
473
+
474
+ # Weighted features (attention mechanism's output)
475
+ weighted_features = x * attention_weights
476
+
477
+ # Residual connection
478
+ residual_connection = x + weighted_features
479
+
480
+ return residual_connection, attention_weights
481
+
482
+
483
+ class _MultiHeadAttentionLayer(nn.Module):
484
+ """
485
+ A wrapper for the standard `torch.nn.MultiheadAttention` layer.
486
+
487
+ This layer treats the entire input feature vector as a single item in a
488
+ sequence and applies self-attention to it. It is followed by a residual
489
+ connection and layer normalization, which is a standard block in
490
+ Transformer-style models.
491
+ """
492
+ def __init__(self, num_features: int, num_heads: int, dropout: float):
493
+ super().__init__()
494
+ self.attention = nn.MultiheadAttention(
495
+ embed_dim=num_features,
496
+ num_heads=num_heads,
497
+ dropout=dropout,
498
+ batch_first=True # Crucial for (batch, seq, feature) input
499
+ )
500
+ self.layer_norm = nn.LayerNorm(num_features)
501
+
502
+ def forward(self, x: torch.Tensor) -> tuple[torch.Tensor, torch.Tensor]:
503
+ # x shape: (batch_size, num_features)
504
+
505
+ # nn.MultiheadAttention expects a sequence dimension.
506
+ # We add a sequence dimension of length 1.
507
+ # x_reshaped shape: (batch_size, 1, num_features)
508
+ x_reshaped = x.unsqueeze(1)
509
+
510
+ # Apply self-attention. query, key, and value are all the same.
511
+ # attn_output shape: (batch_size, 1, num_features)
512
+ # attn_weights shape: (batch_size, 1, 1)
513
+ attn_output, attn_weights = self.attention(
514
+ query=x_reshaped,
515
+ key=x_reshaped,
516
+ value=x_reshaped,
517
+ need_weights=True,
518
+ average_attn_weights=True # Average weights across heads
519
+ )
520
+
521
+ # Add residual connection and apply layer normalization (Post-LN)
522
+ out = self.layer_norm(x + attn_output.squeeze(1))
523
+
524
+ # Squeeze weights for a consistent output shape
525
+ return out, attn_weights.squeeze()
105
526
 
106
527
 
107
528
  class SequencePredictorLSTM(nn.Module):