@@ -45,7 +45,7 @@ def wave_net_activation(x):
45
45
46
46
47
47
def residual_block (x , s , i , activation , nb_filters , kernel_size , padding , dropout_rate = 0 , name = '' ):
48
- # type: (Layer, int, int, str, int, int, float, str) -> Tuple[Layer, Layer]
48
+ # type: (Layer, int, int, str, int, int, str, float, str) -> Tuple[Layer, Layer]
49
49
"""Defines the residual block for the WaveNet TCN
50
50
51
51
Args:
@@ -67,7 +67,7 @@ def residual_block(x, s, i, activation, nb_filters, kernel_size, padding, dropou
67
67
original_x = x
68
68
conv = Conv1D (filters = nb_filters , kernel_size = kernel_size ,
69
69
dilation_rate = i , padding = padding ,
70
- name = name + '_dilated_conv_% d_tanh_s%d' % (i , s ))(x )
70
+ name = name + '_d_%s_conv_% d_tanh_s%d' % (padding , i , s ))(x )
71
71
if activation == 'norm_relu' :
72
72
x = Activation ('relu' )(conv )
73
73
x = Lambda (channel_normalization )(x )
@@ -100,8 +100,10 @@ def is_power_of_two(num):
100
100
class TCN :
101
101
"""Creates a TCN layer.
102
102
103
+ Input shape:
104
+ A tensor of shape (batch_size, timesteps, input_dim).
105
+
103
106
Args:
104
- input_layer: A tensor of shape (batch_size, timesteps, input_dim).
105
107
nb_filters: The number of filters to use in the convolutional layers.
106
108
kernel_size: The size of the kernel to use in each convolutional layer.
107
109
dilations: The list of the dilations. Example is: [1, 2, 4, 8, 16, 32, 64].
@@ -121,7 +123,7 @@ def __init__(self,
121
123
nb_filters = 64 ,
122
124
kernel_size = 2 ,
123
125
nb_stacks = 1 ,
124
- dilations = None ,
126
+ dilations = [ 1 , 2 , 4 , 8 , 16 , 32 ] ,
125
127
activation = 'norm_relu' ,
126
128
padding = 'causal' ,
127
129
use_skip_connections = True ,
@@ -139,12 +141,8 @@ def __init__(self,
139
141
self .nb_filters = nb_filters
140
142
self .padding = padding
141
143
142
- # backwards incompatibility warning.
143
- # o = tcn.TCN(i, return_sequences=False) =>
144
- # o = tcn.TCN(return_sequences=False)(i)
145
-
146
144
if padding != 'causal' and padding != 'same' :
147
- raise ValueError ("Only 'causal' or 'same' paddings are compatible for this layer." )
145
+ raise ValueError ("Only 'causal' or 'same' padding are compatible for this layer." )
148
146
149
147
if not isinstance (nb_filters , int ):
150
148
print ('An interface change occurred after the version 2.1.2.' )
@@ -154,8 +152,6 @@ def __init__(self,
154
152
raise Exception ()
155
153
156
154
def __call__ (self , inputs ):
157
- if self .dilations is None :
158
- self .dilations = [1 , 2 , 4 , 8 , 16 , 32 ]
159
155
x = inputs
160
156
x = Convolution1D (self .nb_filters , 1 , padding = self .padding , name = self .name + '_initial_conv' )(x )
161
157
skip_connections = []
0 commit comments