Using TCN as an Encoder
jlim13 opened this issue · 3 comments
jlim13 commented
How can we use the TCN as an encoder? How can we use the network to produce a single vector representation of the input like the context vector for RNNs? Do we take the last timestep of the output?
eayvali commented
For data input shape (num_samples, timesteps, num_features), you can connect a TCN layer to LSTM/GRU layer as follows:
input_layer = keras.Input(shape=(timesteps, num_features))
cnn_layer=TCN(nb_filters=32,return_sequences=True)(input_layer)
lstm_layer=LSTM(100)(cnn_layer)
philipperemy commented
@jlim13 I would say you should use return_sequences=False
to return the last timestemp. And then you can unroll with your decoder. TCN are LSTM classes are inter-changeable. So any example you find that works with LSTM for encoder-decoder should work for TCN.
philipperemy commented
The answer of @eayvali also work, you can stack a TCN and a LSTM to produce a vector.