2017-05-17 14 views
2

thiscaffeの実装に基づいて、マルチタスクネットワークのTensorflowバージョンを実装します。マルチタスクネットワークのValueError:シェイプはランク0である必要がありますが、ランク1です

ネットワークは、このtensorflow graphとして可視化されるが、私はエラーを取得:私はどのようにこの問題を解決するには考えている

Traceback (most recent call last): 
    File "/home/bill/pyvenv/py35/lib/python3.5/site-packages/tensorflow/python/framework/common_shapes.py", line 671, in _call_cpp_shape_fn_impl 
    input_tensors_as_shapes, status) 
    File "/usr/lib/python3.5/contextlib.py", line 66, in __exit__ 
    next(self.gen) 
    File "/home/bill/pyvenv/py35/lib/python3.5/site-packages/tensorflow/python/framework/errors_impl.py", line 466, in raise_exception_on_not_ok_status 
    pywrap_tensorflow.TF_GetCode(status)) 
tensorflow.python.framework.errors_impl.InvalidArgumentError: Shape must be rank 0 but is rank 1 for 'GradientDescent/update_heatmap/spatial_net/conv1/weights/ApplyGradientDescent' (op: 'ApplyGradientDescent') with input shapes: [5,5,3,128], [1], [5,5,3,128]. 

During handling of the above exception, another exception occurred: 

Traceback (most recent call last): 
    File "/home/bill/Development/scan_to_image/scan_to_image/train_by_heatmap_with_tfrecords.py", line 322, in <module> 
    train_from_tfrecords(dataset_folder) 
    File "/home/bill/Development/scan_to_image/scan_to_image/train_by_heatmap_with_tfrecords.py", line 190, in train_from_tfrecords 
    training_operation = slim.learning.create_train_op(total_loss, optimizer) 
    File "/home/bill/pyvenv/py35/lib/python3.5/site-packages/tensorflow/contrib/slim/python/slim/learning.py", line 436, in create_train_op 
    colocate_gradients_with_ops=colocate_gradients_with_ops) 
    File "/home/bill/pyvenv/py35/lib/python3.5/site-packages/tensorflow/contrib/training/python/training/training.py", line 448, in create_train_op 
    grad_updates = optimizer.apply_gradients(grads, global_step=global_step) 
    File "/home/bill/pyvenv/py35/lib/python3.5/site-packages/tensorflow/python/training/optimizer.py", line 456, in apply_gradients 
    update_ops.append(processor.update_op(self, grad)) 
    File "/home/bill/pyvenv/py35/lib/python3.5/site-packages/tensorflow/python/training/optimizer.py", line 97, in update_op 
    return optimizer._apply_dense(g, self._v) # pylint: disable=protected-access 
    File "/home/bill/pyvenv/py35/lib/python3.5/site-packages/tensorflow/python/training/gradient_descent.py", line 50, in _apply_dense 
    use_locking=self._use_locking).op 
    File "/home/bill/pyvenv/py35/lib/python3.5/site-packages/tensorflow/python/training/gen_training_ops.py", line 306, in apply_gradient_descent 
    name=name) 
    File "/home/bill/pyvenv/py35/lib/python3.5/site-packages/tensorflow/python/framework/op_def_library.py", line 768, in apply_op 
    op_def=op_def) 
    File "/home/bill/pyvenv/py35/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 2338, in create_op 
    set_shapes_for_outputs(ret) 
    File "/home/bill/pyvenv/py35/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 1719, in set_shapes_for_outputs 
    shapes = shape_func(op) 
    File "/home/bill/pyvenv/py35/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 1669, in call_with_requiring 
    return call_cpp_shape_fn(op, require_shape_fn=True) 
    File "/home/bill/pyvenv/py35/lib/python3.5/site-packages/tensorflow/python/framework/common_shapes.py", line 610, in call_cpp_shape_fn 
    debug_python_shape_fn, require_shape_fn) 
    File "/home/bill/pyvenv/py35/lib/python3.5/site-packages/tensorflow/python/framework/common_shapes.py", line 676, in _call_cpp_shape_fn_impl 
    raise ValueError(err.message) 
ValueError: Shape must be rank 0 but is rank 1 for 'GradientDescent/update_heatmap/spatial_net/conv1/weights/ApplyGradientDescent' (op: 'ApplyGradientDescent') with input shapes: [5,5,3,128], [1], [5,5,3,128]. 

を。

+0

私の実装はこちらです(https://gist.github.com/xiekuncn/90ef75357d8d9923d83b6ff3a520e195)。 –

答えて

1

1D Tesnorとして学習率を宣言しましたが、スカラーである必要があります。learning_rate = tf.placeholder(tf.float64, shape=[], name="lr")

+0

ありがとうございました。 –

関連する問題