Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion qlib/contrib/model/pytorch_tcn_ts.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,4 +294,4 @@ def __init__(self, num_input, output_size, num_channels, kernel_size, dropout):
def forward(self, x):
output = self.tcn(x)
output = self.linear(output[:, :, -1])
return output.squeeze()
return output.squeeze(-1)
10 changes: 10 additions & 0 deletions tests/model/test_pytorch_tcn_ts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import torch

from qlib.contrib.model.pytorch_tcn_ts import TCNModel


def test_tcn_ts_model_keeps_batch_dimension_for_single_sample():
model = TCNModel(num_input=3, output_size=1, num_channels=[4], kernel_size=2, dropout=0.0)

assert model(torch.randn(1, 3, 8)).shape == (1,)
assert model(torch.randn(2, 3, 8)).shape == (2,)