-
-
Save priya-gitTest/c6c06b2b294a4ccc52aaf658db326290 to your computer and use it in GitHub Desktop.
Temporal Convolutional Networks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class TemporalConvNet(tf.layers.Layer): | |
| def __init__(self, num_channels, kernel_size=2, dropout=0.2, | |
| trainable=True, name=None, dtype=None, | |
| activity_regularizer=None, **kwargs): | |
| super(TemporalConvNet, self).__init__( | |
| trainable=trainable, dtype=dtype, | |
| activity_regularizer=activity_regularizer, | |
| name=name, **kwargs | |
| ) | |
| self.layers = [] | |
| num_levels = len(num_channels) | |
| for i in range(num_levels): | |
| dilation_size = 2 ** i | |
| out_channels = num_channels[i] | |
| self.layers.append( | |
| TemporalBlock(out_channels, kernel_size, strides=1, dilation_rate=dilation_size, | |
| dropout=dropout, name="tblock_{}".format(i)) | |
| ) | |
| def call(self, inputs, training=True): | |
| outputs = inputs | |
| for layer in self.layers: | |
| outputs = layer(outputs, training=training) | |
| return outputs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment