赞
踩
下面是一个完整的代码实现,使用了 TensorFlow 2.x 实现了一个简单的带有注意力机制的 Temporal Convolutional Network(TCN)进行回归预测:
``` import tensorflow as tf from tensorflow.keras.layers import Input, Conv1D, Dense, Dropout, Activation, Add, GlobalMaxPool1D from tensorflow.keras.models import Model from tensorflow.keras.optimizers import Adam
class TCN(Model): def init(self, num_channels, kernel_size, dropout): super(TCN, self).init() self.num_channels = num_channels self.kernel_size = kernel_size self.dropout = dropout self.conv1 = Conv1D(self.num_channels, self.kernel_size, padding='causal', activation='relu') self.dropout1 = Dropout(self.dropout) self.conv2 = Conv1D(self.num_channels, self.kernel_size, padding='causal', activation='relu') self.dropout2 = Dropout(se
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。