Я работал над учебником CIFAR-10 по Tensorflow, но я не могу заставить любую из моих объявлений переменных работать. Даже что-то просто, как:Невозможно выполнить простую инициализацию переменной - «тип данных непонят»
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 Я согласен, что это действительно сбивает меня с толку. Учебное пособие, по-видимому, предполагает, что нужно передать их, как в примере, но на самом деле должно быть явно указано имя аргумента. Это раздражало. Спасибо, что задал вопрос. –