Returns a Dimension that combines the information in `self` and `other`. Dimensions are combined as follows: ```python tf.compat.v1.Dimension(n) .merge_with(tf.compat.v1.Dimension(n)) == tf.compat.v1.Dimension(n) tf.compat.v1.Dimension(n) .merge_with(tf.compat.v1.Dimens
(self, other)
| 275 | (self, other)) |
| 276 | |
| 277 | def merge_with(self, other): |
| 278 | """Returns a Dimension that combines the information in `self` and `other`. |
| 279 | |
| 280 | Dimensions are combined as follows: |
| 281 | |
| 282 | ```python |
| 283 | tf.compat.v1.Dimension(n) .merge_with(tf.compat.v1.Dimension(n)) == |
| 284 | tf.compat.v1.Dimension(n) |
| 285 | tf.compat.v1.Dimension(n) .merge_with(tf.compat.v1.Dimension(None)) == |
| 286 | tf.compat.v1.Dimension(n) |
| 287 | tf.compat.v1.Dimension(None).merge_with(tf.compat.v1.Dimension(n)) == |
| 288 | tf.compat.v1.Dimension(n) |
| 289 | # equivalent to tf.compat.v1.Dimension(None) |
| 290 | tf.compat.v1.Dimension(None).merge_with(tf.compat.v1.Dimension(None)) |
| 291 | |
| 292 | # raises ValueError for n != m |
| 293 | tf.compat.v1.Dimension(n) .merge_with(tf.compat.v1.Dimension(m)) |
| 294 | ``` |
| 295 | |
| 296 | Args: |
| 297 | other: Another Dimension. |
| 298 | |
| 299 | Returns: |
| 300 | A Dimension containing the combined information of `self` and |
| 301 | `other`. |
| 302 | |
| 303 | Raises: |
| 304 | ValueError: If `self` and `other` are not compatible (see |
| 305 | is_compatible_with). |
| 306 | """ |
| 307 | try: |
| 308 | other = as_dimension(other) |
| 309 | except (TypeError, ValueError): |
| 310 | return NotImplemented |
| 311 | self.assert_is_compatible_with(other) |
| 312 | if self._value is None: |
| 313 | return Dimension(other.value) |
| 314 | else: |
| 315 | return Dimension(self._value) |
| 316 | |
| 317 | def __add__(self, other): |
| 318 | """Returns the sum of `self` and `other`. |