Keras - RepeatVector Layers



RepeatVector is used to repeat the input for set number, n of times. For example, if RepeatVector with argument 16 is applied to layer having input shape as (batch_size, 32), then the output shape of the layer will be (batch_size, 16, 32)

RepeatVector has one arguments and it is as follows −

keras.layers.RepeatVector(n)

A simple example to use RepeatVector layers is as follows −

>>> from keras.models import Sequential 
>>> from keras.layers import Activation, Dense, RepeatVector 
>>> 
>>> 
>>> model = Sequential() 
>>> layer_1 = Dense(16, input_shape=(8,)) 
>>> model.add(layer_1) 
>>> layer_2 = RepeatVector(16) 
>>> model.add(layer_2) 
>>> layer_2.input_shape (None, 16) 
>>> layer_2.output_shape
(None, 16, 16)
>>>

where, 16 is set as repeat times.

Advertisements