<p>I want to get some encodings for temporal data (with a highly varying number of timesteps).</p>
<p>The dataset is of the format: <code>array&lt;TemporalSample = list, SAMPLE_COUNT&gt;</code> (where <code>array</code> is fixed size and <code>list</code> is variable).</p>
<p>The <code>TemporalSample</code>s are simply <code>list</code>s of size <code>TemporalSample::timesteps</code></p>
<hr />
<p>Currently, I use a standard RNN network of the form:</p>
<pre><code>model = keras.Sequential()
model.add(layers.GRU(256, dropout=0.1, input_shape=[None, 1], return_sequences=False))
model.add(layers.Dense(len(output_names), activation=&quot;softmax&quot;))
model.compile(optimizer='adam',
              loss='categorical_crossentropy',
              metrics=['accuracy'])
model.summary()
</code></pre>
<p>The problem is my inputs have variable lengths, if I want an auto-encoder, my output needs to be variable-length (just like my input), and I need an inverse RNN layer (something like <code>layers.InverseGRU(output_shape=[None, 1])</code>) but from my reading this seems like not something that has been considered/done before.</p>
<p>Is this at all possible?</p>

CC BY-SA 4.0
2021-04-11T01:48:04.870Z
As I wrote for the other post, it's not clear to me whether this is a programming issue. Can you clarify this?
nbro
CC BY-SA 4.0
2021-04-11T02:03:24.153Z
@nbro I'm asking if I can build a RNN auto encoder - using python examples for context
Tobi Akinyemi
CC BY-SA 4.0
2021-04-11T02:05:02.003Z
For some reason, it wasn't clear to me after the first reading that you just want to build an AE with recurrent layers.
nbro
CC BY-SA 4.0
2021-04-11T02:06:10.863Z
@nbro the main problem is i have variable length timesteps
Tobi Akinyemi
CC BY-SA 4.0
2021-04-11T02:13:06.127Z
Ok, I will leave this post open, although you also asked the same question [here](https://stackoverflow.com/q/67028618/3924118), so that maybe someone tries to give you an answer ;)
nbro
CC BY-SA 4.0
2021-04-11T02:13:39.457Z
@nbro I asked here as this is a more AI focused community (the answer on SO is wrong)
Tobi Akinyemi
CC BY-SA 4.0
2021-04-11T02:14:46.897Z
What about this: https://machinelearningmastery.com/lstm-autoencoders/?
nbro
CC BY-SA 4.0
2021-04-11T02:17:22.343Z
@nbro doesn't account for variable timesteps
Tobi Akinyemi
CC BY-SA 4.0
2021-04-11T02:19:14.593Z
Ok. I didn't read that article, but it seemed to go in the direction of what you were asking (although, to be honest, I didn't carefully read your post).
nbro
CC BY-SA 4.0
2021-04-11T02:27:15.120Z
@nbro I actually have a working encoder now (at the time of writing this post I didn't); however, I'm still interested to see if anyone has any differing techniques
Tobi Akinyemi
<machine-learning><tensorflow><python><keras><recurrent-neural-networks>
Is a true RNN auto encoder possible with Keras/TF
Tobi Akinyemi
# Is a true RNN auto encoder possible with Keras/TF

(Asked by: username_0 on 2021-04-09)

I want to get some encodings for temporal data (with a highly varying number of timesteps).
The dataset is of the format: array (where array is fixed size and list is variable).
The TemporalSamples are simply lists of size TemporalSample::timesteps

Currently, I use a standard RNN network of the form:
model = keras.Sequential()
model.add(layers.GRU(256, dropout=0.1, input_shape=[None, 1], return_sequences=False))
model.add(layers.Dense(len(output_names), activation="softmax"))
model.compile(optimizer='adam',
              loss='categorical_crossentropy',
              metrics=['accuracy'])
model.summary()

The problem is my inputs have variable lengths, if I want an auto-encoder, my output needs to be variable-length (just like my input), and I need an inverse RNN layer (something like layers.InverseGRU(output_shape=[None, 1])) but from my reading this seems like not something that has been considered/done before.
Is this at all possible?

**Tags:** machine-learning, tensorflow, python, keras, recurrent-neural-networks

> **Comments:**
> **username_1**: As I wrote for the other post, it's not clear to me whether this is a programming issue. Can you clarify this?  
> **username_0**: @username_1 I'm asking if I can build a RNN auto encoder - using python examples for context  
> **username_1**: For some reason, it wasn't clear to me after the first reading that you just want to build an AE with recurrent layers.  
> **username_0**: @username_1 the main problem is i have variable length timesteps  
> **username_1**: Ok, I will leave this post open, although you also asked the same question [here](https://stackoverflow.com/q/67028618/3924118), so that maybe someone tries to give you an answer ;)  
> **username_0**: @username_1 I asked here as this is a more AI focused community (the answer on SO is wrong)  
> **username_1**: What about this: https://machinelearningmastery.com/lstm-autoencoders/?  
> **username_0**: @username_1 doesn't account for variable timesteps  
> **username_1**: Ok. I didn't read that article, but it seemed to go in the direction of what you were asking (although, to be honest, I didn't carefully read your post).  
> **username_0**: @username_1 I actually have a working encoder now (at the time of writing this post I didn't); however, I'm still interested to see if anyone has any differing techniques  

---

## 0 answers

