2016-10-25 1 views
2

나는 간단한 RNNCell을 사용하려고 노력하고 있습니다. 이 간단한 코드 :tensorflow requested = float64_ref, actual = float64

Metadata-Version: 2.0 Name: tensorflow Version: 0.11.0rc1 Summary: TensorFlow helps the tensors flow Home-page: http://tensorflow.org/ Author: Google Inc. Author-email: [email protected] Installer: pip License: Apache 2.0 Location: /Users/ethan/env/lib/python2.7/site-packages Requires: mock, protobuf, numpy, wheel, six Classifiers: Development Status :: 4 - Beta Intended Audience :: Developers Intended Audience :: Education Intended Audience :: Science/Research License :: OSI Approved :: Apache Software License Programming Language :: Python :: 2.7 Topic :: Scientific/Engineering :: Mathematics Topic :: Software Development :: Libraries :: Python Modules Topic :: Software Development :: Libraries Entry-points: [console_scripts] tensorboard = tensorflow.tensorboard.tensorboard:main

감사 :

Traceback (most recent call last): 
    File "scrap.py", line 38, in <module> 
    g, _ = tf.nn.rnn_cell.BasicRNNCell(2)(x, x) 
    File "/Users/ethan/env/lib/python2.7/site-packages/tensorflow/python/ops/rnn_cell.py", line 199, in __call__ 
    output = self._activation(_linear([inputs, state], self._num_units, True)) 
    File "/Users/ethan/env/lib/python2.7/site-packages/tensorflow/python/ops/rnn_cell.py", line 903, in _linear 
    "Matrix", [total_arg_size, output_size], dtype=dtype) 
    File "/Users/ethan/env/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 1022, in get_variable 
    custom_getter=custom_getter) 
    File "/Users/ethan/env/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 849, in get_variable 
    custom_getter=custom_getter) 
    File "/Users/ethan/env/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 345, in get_variable 
    validate_shape=validate_shape) 
    File "/Users/ethan/env/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 330, in _true_getter 
    caching_device=caching_device, validate_shape=validate_shape) 
    File "/Users/ethan/env/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 676, in _get_single_variable 
    validate_shape=validate_shape) 
    File "/Users/ethan/env/lib/python2.7/site-packages/tensorflow/python/ops/variables.py", line 215, in __init__ 
    dtype=dtype) 
    File "/Users/ethan/env/lib/python2.7/site-packages/tensorflow/python/ops/variables.py", line 288, in _init_from_args 
    initial_value(), name="initial_value", dtype=dtype) 
    File "/Users/ethan/env/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 666, in <lambda> 
    shape.as_list(), dtype=dtype, partition_info=partition_info) 
    File "/Users/ethan/env/lib/python2.7/site-packages/tensorflow/python/ops/init_ops.py", line 280, in _initializer 
    dtype, seed=seed) 
    File "/Users/ethan/env/lib/python2.7/site-packages/tensorflow/python/ops/random_ops.py", line 232, in random_uniform 
    minval = ops.convert_to_tensor(minval, dtype=dtype, name="min") 
    File "/Users/ethan/env/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 671, in convert_to_tensor 
    dtype.name, ret.dtype.name)) 
RuntimeError: min: Conversion function <function _constant_tensor_conversion_function at 0x112053c08> for type <type 'object'> returned incompatible dtype: requested = float64_ref, actual = float64 

pip show tensorflow의 출력은 다음과 같습니다

with tf.Session() as sess: 
    x = tf.Variable(np.ones((2, 3))) 
    tf.initialize_all_variables().run() 
    out, state = BasicRNNCell(4)(x, x) 

다음과 같은 오류가 발생합니다!

답변

0

, 클래스 텐서는 float64_ref의 DTYPE을 가지고 있으며, 클래스 변수는 float64의 DTYPE있다. 그리고 BasicRNNCell은 변수가 아닌 Tensor를 입력으로 필요로합니다. 코드에서 , x = tf.Variable(...)x = tf.convert_to_tensor(...)

+0

솔루션이 제대로 작동하는지 확인했지만 약간 혼란 스럽습니다. 변수로 입력 할 수없는 이유는 무엇입니까? – ethanabrooks

2

나는 Tensorflow의 버그라고 생각하며 open an issue on GitHub으로 초대합니다.

당신은 inputs 매개 변수로이 값을 대신 float64 xfloat64_ref를 생성하고 전달할 수 tf.identity를 사용하여이 문제를 해결하려면. TensorFlow에서

import tensorflow as tf 
import numpy as np 

with tf.Session() as sess: 
    x = tf.Variable(np.ones((2, 3))) 
    sess.run(tf.initialize_all_variables()) 
    out, state = tf.nn.rnn_cell.BasicRNNCell(4)(tf.identity(x), x) 
+0

마지막으로 문제를 열기로 주변에 도착으로 변경해야합니다. 추천 해 주셔서 감사합니다. – ethanabrooks

+0

이것에 대한 실질적인 해결책이 있습니까? 같은 오류가 발생하고 심지어 간단한 코드가 발생합니다 : '>>> tf로 가져 오기 tensorflow >>> tf.Variable (initial_value = [0.0], dtype = tf.float64) – sirgogo

+0

당신은 어떤 tf 버전입니까? 사용 하시겠습니까? 최신의 경우 코드 실행에 아무런 문제가 없습니다. – nessuno