Can someone explain what the ‘unit’ does exactly in the model?

First GRU layer. To generate the GRU layer, use 128 units.

```
output_x = GRU(units=..., return_sequences = ...)(input_x)
```

I mean for example here it is mentioned to use 128 units, why 128, and what would be the effect of increasing or decreasing the unit number?

Hello @Leen_Hakki,

Let’s check out this example from the TF doc:

Look at the first 5 lines which is an example of `units = 4`

. The 5th line tells you that, if we give such a GRU an input of shape `[32, 10, 8]`

(`32`

samples where each sample has `10`

time steps and `8`

features), it will return us an output of shape `[32, 4]`

.

We have `32`

there because there are 32 samples. We have `4`

there because we used `units=4`

. In other words, we have 4 transformed features by the GRU layer.

If we increase it from `4`

to `256`

, the layer will produce 256 transformed features. In other words, we increased the capacity of the layer to learn more. This will also increase the training time. Similarly, if we decrease it from `4`

to `1`

, it will learn less and faster.

Cheers,

Raymond

1 Like