私は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
、それは間違っていました。
ありがとうございます!
ドキュメントを確認したかどうか不明 - ここに投稿する前に、これが最初のことだったはずです。コードを 'biases = tf.get_variable( 'biases'、[64]、initializer = tf.constant_initializer(0.0))に変更してください。 – shekkizh
私は文書をチェックしました。私はpythonには新しく、bradden_grossが修正を指摘するまでキーワードの引数を使う必要性を知らなかった。 – gwtw14
@ gwtw14私はこれも私にとって本当に混乱していることに同意します。このチュートリアルでは、例のように渡す必要があることを示唆しているようですが、実際には引数の名前を明示的に指定する必要があります。それは迷惑だった。しかし、質問をしてくれてありがとう。 –