允許 TF 中的 V1 和 V2 行為所需的兼容性實用程序。
用法
tf.compat.dimension_value(
dimension
)
參數
-
dimension
Dimension
實例、整數或無。
返回
- 一個普通值,即整數或無。
在 TF 2.0 發布之前,我們需要 TensorShape
的舊行為與新行為共存。該實用程序是兩者之間的橋梁。
訪問 TensorShape 維度的值時,請使用此實用程序,如下所示:
# If you had this in your V1 code:
value = tensor_shape[i].value
# Use `dimension_value` as direct replacement compatible with both V1 & V2:
value = dimension_value(tensor_shape[i])
# This would be the V2 equivalent:
value = tensor_shape[i] # Warning:this will return the dim value in V2!
相關用法
- Python tf.compat.dimension_at_index用法及代碼示例
- Python tf.compat.v1.distributions.Multinomial.stddev用法及代碼示例
- Python tf.compat.v1.distribute.MirroredStrategy.experimental_distribute_dataset用法及代碼示例
- Python tf.compat.v1.data.TFRecordDataset.interleave用法及代碼示例
- Python tf.compat.v1.distributions.Bernoulli.cross_entropy用法及代碼示例
- Python tf.compat.v1.Variable.eval用法及代碼示例
- Python tf.compat.v1.train.FtrlOptimizer.compute_gradients用法及代碼示例
- Python tf.compat.v1.layers.conv3d用法及代碼示例
- Python tf.compat.v1.strings.length用法及代碼示例
- Python tf.compat.v1.data.Dataset.snapshot用法及代碼示例
- Python tf.compat.v1.data.experimental.SqlDataset.reduce用法及代碼示例
- Python tf.compat.v1.feature_column.categorical_column_with_vocabulary_file用法及代碼示例
- Python tf.compat.v1.data.TextLineDataset.from_tensors用法及代碼示例
- Python tf.compat.v1.variable_scope用法及代碼示例
- Python tf.compat.v1.data.experimental.SqlDataset.as_numpy_iterator用法及代碼示例
- Python tf.compat.v1.distributions.Bernoulli.covariance用法及代碼示例
- Python tf.compat.v1.placeholder用法及代碼示例
- Python tf.compat.v1.layers.Conv3D用法及代碼示例
- Python tf.compat.v1.train.get_or_create_global_step用法及代碼示例
- Python tf.compat.v1.nn.static_rnn用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.compat.dimension_value。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。