gpt4 book ai didi

tensorflow - 无法对变量进行简单初始化 - 'data type not understood'

转载 作者:行者123 更新时间:2023-12-03 22:41:49 25 4
gpt4 key购买 nike

我正在运行 Tensorflow 上的 CIFAR-10 教程,但我无法让我的任何变量声明起作用。即使是一些简单的东西:

biases = tf.get_variable('biases', [64], tf.constant_initializer(0.0))

给出错误:

   ---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-23-86228512ca30> in <module>()
----> 1 biases = tf.get_variable('biases', [64], tf.constant_initializer(0.0))

/home/mmm/programs/anaconda/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.pyc in get_variable(name, shape, dtype, initializer, regularizer, trainable, collections, caching_device, partitioner, validate_shape)
730 initializer=initializer, regularizer=regularizer, trainable=trainable,
731 collections=collections, caching_device=caching_device,
--> 732 partitioner=partitioner, validate_shape=validate_shape)
733
734

/home/mmm/programs/anaconda/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.pyc in get_variable(self, var_store, name, shape, dtype, initializer, regularizer, trainable, collections, caching_device, partitioner, validate_shape)
594 regularizer=regularizer, reuse=self.reuse, trainable=trainable,
595 collections=collections, caching_device=caching_device,
--> 596 partitioner=partitioner, validate_shape=validate_shape)
597
598 def _get_partitioned_variable(

/home/mmm/programs/anaconda/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.pyc in get_variable(self, name, shape, dtype, initializer, regularizer, reuse, trainable, collections, caching_device, partitioner, validate_shape)
159 initializer=initializer, regularizer=regularizer, reuse=reuse,
160 trainable=trainable, collections=collections,
--> 161 caching_device=caching_device, validate_shape=validate_shape)
162
163 def _get_partitioned_variable(

/home/mmm/programs/anaconda/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.pyc in _get_single_variable(self, name, shape, dtype, initializer, regularizer, reuse, trainable, collections, caching_device, validate_shape)
423
424 should_check = reuse is not None
--> 425 dtype = dtypes.as_dtype(dtype)
426 shape = tensor_shape.as_shape(shape)
427

/home/mmm/programs/anaconda/lib/python2.7/site-packages/tensorflow/python/framework/dtypes.pyc in as_dtype(type_value)
534
535 for key, val in _NP_TO_TF:
--> 536 if key == type_value:
537 return val
538

TypeError: data type not understood

我很想知道哪里出了问题,哪里出了问题。

提前致谢!

最佳答案

我不熟悉该教程,但看起来您提供了 tf.constant_initializer(0.0) 作为您的数据类型,它返回一个初始化程序以生成常量。 tf.get_variable() 的第三个参数应该是变量的数据类型,对于偏差变量,它通常是 tf.float32 或 tf.float64 之类的。

关于tensorflow - 无法对变量进行简单初始化 - 'data type not understood',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37975861/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com