# How a matrix is given input to RNN cell

import tensorflow as tf
from tensorflow.keras import layers

tf.random.set_seed(21)
vec = tf.random.normal([1, 2, 4], dtype=tf.float32)
print(vec)

lstm = layers.SimpleRNN(3)
output = lstm(vec)
print(output)

output-
tf.Tensor(
[[[-2.0809765 1.7485927 0.7655805 -1.5298417 ]
[-1.1606345 -1.9904611 -0.8419037 0.02641571]]], shape=(1, 2, 4), dtype=float32)

tf.Tensor([[ 0.89376044 0.8860847 -0.5505087 ]], shape=(1, 3), dtype=float32)

As we know that RNN cell takes vector as an input at each time step. How a matrix is given input to a RNN cell at each time step (In what way it is internally working or converting this matrix for each time step)?
My assumption is that it should throw an error because there should be 3 rows corresponding to each time step .i.e input shape should be (1, 3, 4).

`tf.keras.layers.SimpleRNN` takes input of shape 3D tensor, with shape `[batch, timesteps, feature]`. For more information read tf.keras.layers.SimpleRNN  |  TensorFlow Core v2.8.0.

If you want feed matrix as input, you can simply flatten the input
example, Assuming that your `(3,4)` is a matrix,

``````input = tf.keras.layers.Input((3,4)) #none,3,4
x = tf.keras.layers.Flatten()(input)  #none,12
``````