Table of contents
Custom implementation of tcn layer
torch-tcn library
pip install torch-tcn
Sample code
import torch
from torch import nn
from tcn import TCNLayer
batch_size = 16
seq_length = 100 # 序列长度
n_features = 32 # 特征数量
n_outputs = 10 # 输出大小
# 输入数据的形状为 (batch_size, seq_length, n_features)
# TCNLayer期望的输入形状为 (batch_size, n_features, seq_length)
# 因此,可能需要对输入进行转置
x = torch.randn(batch_