AlexanderLutsenko / nobuco

Pytorch to Keras/Tensorflow/TFLite conversion made intuitive
MIT License
272 stars 17 forks source link

Modes for torch.nn.functional.pad and tf.pad #49

Closed happyTonakai closed 5 months ago

happyTonakai commented 5 months ago

PyTorch has constant, reflect, replicate, and circular padding modes while TensorFlow has CONSTANT, REFLECT, and SYMMETRIC.

PyTorch’s reflect and TensorFlow’s REFLECT are similar. PyTorch’s replicate is similar to TensorFlow’s SYMMETRIC. TensorFlow does not have an equivalent for PyTorch’s circular mode.

When I try to convert a replicate pad to tf, it seems that nobuco sends REPLICATE to tf.pad and it raise an error that it doesn't have such a mode.

ValueError: Exception encountered when calling layer "tf.pad" (type TFOpLambda).

Value of argument `mode` expected to be one of "CONSTANT", "REFLECT", or "SYMMETRIC". Received `mode` = REPLICATE
AlexanderLutsenko commented 5 months ago

Hi! I added support for replicate and circular padding in v0.14.5. It's not pretty, but it works.

happyTonakai commented 5 months ago

Thank you for your work! This issue should be closed.