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

Function dtype

tensorflow/python/keras/backend.py:1216–1243  ·  view source on GitHub ↗

Returns the dtype of a Keras tensor or variable, as a string. Arguments: x: Tensor or variable. Returns: String, dtype of `x`. Examples: ```python >>> from keras import backend as K >>> K.dtype(K.placeholder(shape=(2,4,5))) 'float32' >>> K.dtype(K.placeholder(shape=(2,

(x)

Source from the content-addressed store, hash-verified

1214
1215@keras_export('keras.backend.dtype')
1216def dtype(x):
1217 """Returns the dtype of a Keras tensor or variable, as a string.
1218
1219 Arguments:
1220 x: Tensor or variable.
1221
1222 Returns:
1223 String, dtype of `x`.
1224
1225 Examples:
1226 ```python
1227 >>> from keras import backend as K
1228 >>> K.dtype(K.placeholder(shape=(2,4,5)))
1229 'float32'
1230 >>> K.dtype(K.placeholder(shape=(2,4,5), dtype='float32'))
1231 'float32'
1232 >>> K.dtype(K.placeholder(shape=(2,4,5), dtype='float64'))
1233 'float64'
1234 # Keras variable
1235 >>> kvar = K.variable(np.array([[1, 2], [3, 4]]))
1236 >>> K.dtype(kvar)
1237 'float32'
1238 >>> kvar = K.variable(np.array([[1, 2], [3, 4]]), dtype='float32')
1239 >>> K.dtype(kvar)
1240 'float32'
1241 ```
1242 """
1243 return x.dtype.base_dtype.name
1244
1245
1246@keras_export('keras.backend.eval')

Callers 6

set_valueFunction · 0.70
batch_set_valueFunction · 0.70
_testBasicMethod · 0.50
testApproximateEqualMethod · 0.50

Calls

no outgoing calls