Returns the shape of tensor or variable as a tuple of int or None entries. Arguments: x: Tensor or variable. Returns: A tuple of integers (or None entries). Examples: ```python >>> from keras import backend as K >>> input = K.placeholder(shape=(2, 4, 5)) >>> K.int_shape(
(x)
| 1155 | |
| 1156 | @keras_export('keras.backend.int_shape') |
| 1157 | def int_shape(x): |
| 1158 | """Returns the shape of tensor or variable as a tuple of int or None entries. |
| 1159 | |
| 1160 | Arguments: |
| 1161 | x: Tensor or variable. |
| 1162 | |
| 1163 | Returns: |
| 1164 | A tuple of integers (or None entries). |
| 1165 | |
| 1166 | Examples: |
| 1167 | ```python |
| 1168 | >>> from keras import backend as K |
| 1169 | >>> input = K.placeholder(shape=(2, 4, 5)) |
| 1170 | >>> K.int_shape(input) |
| 1171 | (2, 4, 5) |
| 1172 | >>> val = np.array([[1, 2], [3, 4]]) |
| 1173 | >>> kvar = K.variable(value=val) |
| 1174 | >>> K.int_shape(kvar) |
| 1175 | (2, 2) |
| 1176 | ``` |
| 1177 | """ |
| 1178 | try: |
| 1179 | shape = x.shape |
| 1180 | if not isinstance(shape, tuple): |
| 1181 | shape = tuple(shape.as_list()) |
| 1182 | return shape |
| 1183 | except ValueError: |
| 1184 | return None |
| 1185 | |
| 1186 | |
| 1187 | @keras_export('keras.backend.ndim') |
no test coverage detected