5

# Shapes %s and %s are incompatible

Package:

tensorflow

158813

Exception Class:

ValueError

## Raise code

```
"""
Args:
other: Another TensorShape.
Raises:
ValueError: If `self` and `other` do not represent the same shape.
"""
if not self.is_compatible_with(other):
raise ValueError("Shapes %s and %s are incompatible" % (self, other))
def most_specific_compatible_shape(self, other):
"""Returns the most specific TensorShape compatible with `self` and `other`.
* TensorShape([None, 1]) is the most specific TensorShape compatible with
both TensorShape([2, 1]) and TensorShape([5, 1]). Note that
TensorShape(None) is also compatible with above mentioned TensorShapes. """
```

🙏 Scream for help to Ukraine

Today, 25th May 2022, Russia continues bombing and firing Ukraine. Don't trust Russia, they are bombing us and brazenly lying in same time they are not doing this 😠, civilians and children are dying too!
We are screaming and asking exactly you to help us, we want to survive, our families, children, older ones.

Please spread the information, and ask your governemnt to stop Russia by any means. We promise to work extrahard after survival to make the world safer place for all.

Please spread the information, and ask your governemnt to stop Russia by any means. We promise to work extrahard after survival to make the world safer place for all.

## Links to the raise (1)

https://github.com/tensorflow/tensorflow/blob/ba1d02cfc7730048a39e4ba2ad9d3e3863e7cb2f/tensorflow/python/framework/tensor_shape.py#L1161## See also in the other packages (1)

(❌️ No answer)

tensorflow-probability/shapes-s-and-s-ar
## Ways to fix

1

**Tensorflow Dimension** represents the value of one dimension in a TensorShape.

**merge_with **allows us to merge 2 the same dimension tensor **compat **each other.

Error code:

```
import tensorflow as tf
compat_1 = tf.compat.v1.Dimension(3)
compat_2 = tf.compat.v1.Dimension(4)
merge_one =compat_1.merge_with(compat_2)
print(merge_one)
```

As you can see here, we have 2 different dimensions **compat**. That's why the error occurs.

Fix code:

```
import tensorflow as tf
compat_1 = tf.compat.v1.Dimension(3)
compat_2 = tf.compat.v1.Dimension(3)
merge_one =compat_1.merge_with(compat_2)
print(merge_one)
```

### Add a possible fix

Please authorize to post fix