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

Function ndim

tensorflow/python/keras/backend.py:1188–1212  ·  view source on GitHub ↗

Returns the number of axes in a tensor, as an integer. Arguments: x: Tensor or variable. Returns: Integer (scalar), number of axes. Examples: ```python >>> from keras import backend as K >>> input = K.placeholder(shape=(2, 4, 5)) >>> val = np.array([[1, 2], [3, 4]]) >>

(x)

Source from the content-addressed store, hash-verified

1186
1187@keras_export('keras.backend.ndim')
1188def ndim(x):
1189 """Returns the number of axes in a tensor, as an integer.
1190
1191 Arguments:
1192 x: Tensor or variable.
1193
1194 Returns:
1195 Integer (scalar), number of axes.
1196
1197 Examples:
1198 ```python
1199 >>> from keras import backend as K
1200 >>> input = K.placeholder(shape=(2, 4, 5))
1201 >>> val = np.array([[1, 2], [3, 4]])
1202 >>> kvar = K.variable(value=val)
1203 >>> K.ndim(input)
1204 3
1205 >>> K.ndim(kvar)
1206 2
1207 ```
1208 """
1209 dims = x.shape._dims
1210 if dims is not None:
1211 return len(dims)
1212 return None
1213
1214
1215@keras_export('keras.backend.dtype')

Callers 9

dotFunction · 0.85
batch_dotFunction · 0.85
batch_normalizationFunction · 0.85
concatenateFunction · 0.85
repeatFunction · 0.85
switchFunction · 0.85
bias_addFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected