Convert Flatten layer from PyTorch to Tensorflow - Equivalent for start_dim and end_dim

Viewed 219

What is the equivalent of the options start_dim and end_dim of the flatten PyTorch layers, in Tensorflow?

With Tensorlfow we only have data_format and it is not customizable.

1 Answers

I don't think there is an identical implementation in tf. However, you can always use tf.reshape and add the shape yourself with a simple function which takes as arguments input, start_dim and end_dim and outputs the corresponding output shape that torch.flatten would give you.

Related