MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / int_shape

Function int_shape

tensorflow/python/keras/backend.py:1157–1184  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

1155
1156@keras_export('keras.backend.int_shape')
1157def 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')

Callers 5

variableFunction · 0.85
dotFunction · 0.85
resize_imagesFunction · 0.85
local_convFunction · 0.85
bias_addFunction · 0.85

Calls 2

tupleFunction · 0.85
as_listMethod · 0.45

Tested by

no test coverage detected