google-deepmind / learning-to-learn

Learning to Learn in TensorFlow
https://arxiv.org/abs/1606.04474
Apache License 2.0
4.06k stars 599 forks source link

Can not run 'simple' problem. TypeError: ones_initializer() got multiple values for keyword argument 'dtype' #2

Closed hehaodele closed 7 years ago

hehaodele commented 7 years ago

I simply clone the code and run the code by the following flags

flags.DEFINE_string("save_path", None, "Path for saved meta-optimizer.")
flags.DEFINE_integer("num_epochs", 10, "Number of training epochs.")
flags.DEFINE_integer("log_period", 1, "Log period.")
flags.DEFINE_integer("evaluation_period", 1, "Evaluation period.")
flags.DEFINE_integer("evaluation_epochs", 2, "Number of evaluation epochs.")

flags.DEFINE_string("problem", "simple", "Type of problem.")
flags.DEFINE_integer("num_steps", 10,
                     "Number of optimization steps per epoch.")
flags.DEFINE_integer("unroll_length", 5, "Meta-optimizer unroll length.")
flags.DEFINE_float("learning_rate", 0.001, "Learning rate.")
flags.DEFINE_boolean("second_derivatives", False, "Use second derivatives.")

And I get the Error:

Traceback (most recent call last):
  File "train.py", line 115, in <module>
    tf.app.run()
  File "/home/haohe/anaconda2/envs/tf/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 43, in run
    sys.exit(main(sys.argv[:1] + flags_passthrough))
  File "train.py", line 68, in main
    second_derivatives=FLAGS.second_derivatives)
  File "/home/haohe/workspace/learning-to-learn/meta.py", line 398, in meta_minimize
    info = self.meta_loss(make_loss, len_unroll, **kwargs)
  File "/home/haohe/workspace/learning-to-learn/meta.py", line 282, in meta_loss
    x, constants = _get_variables(make_loss)
  File "/home/haohe/workspace/learning-to-learn/meta.py", line 118, in _get_variables
    _wrap_variable_creation(func, custom_getter)
  File "/home/haohe/workspace/learning-to-learn/meta.py", line 91, in _wrap_variable_creation
    return func()
  File "/home/haohe/workspace/learning-to-learn/problems.py", line 49, in build
    initializer=tf.ones_initializer)
  File "/home/haohe/workspace/learning-to-learn/meta.py", line 87, in custom_get_variable
    return original_get_variable(*args, custom_getter=custom_getter, **kwargs)
  File "/home/haohe/anaconda2/envs/tf/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 1024, in get_variable
    custom_getter=custom_getter)
  File "/home/haohe/anaconda2/envs/tf/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 850, in get_variable
    custom_getter=custom_getter)
  File "/home/haohe/anaconda2/envs/tf/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 339, in get_variable
    validate_shape=validate_shape)
  File "/home/haohe/workspace/learning-to-learn/meta.py", line 110, in custom_getter
    variable = getter(name, **kwargs)
  File "/home/haohe/anaconda2/envs/tf/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 331, in _true_getter
    caching_device=caching_device, validate_shape=validate_shape)
  File "/home/haohe/anaconda2/envs/tf/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 677, in _get_single_variable
    expected_shape=shape)
  File "/home/haohe/anaconda2/envs/tf/lib/python2.7/site-packages/tensorflow/python/ops/variables.py", line 224, in __init__
    expected_shape=expected_shape)
  File "/home/haohe/anaconda2/envs/tf/lib/python2.7/site-packages/tensorflow/python/ops/variables.py", line 327, in _init_from_args
    initial_value(), name="initial_value", dtype=dtype)
  File "/home/haohe/anaconda2/envs/tf/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 665, in <lambda>
    shape.as_list(), dtype=dtype, partition_info=partition_info)
TypeError: ones_initializer() got multiple values for keyword argument 'dtype'

I am new to Tensorflow. My tensorflow version the r0.12. Could anyone help me? Any comments will be appreciated.

sergomezcol commented 7 years ago

Thanks for reporting this. We just pushed some changes to make the code compatible with TensorFlow 0.12 (https://github.com/deepmind/learning-to-learn/commit/9b1c649e7a241ba8a70631378146dc92f742deec). That should fix your problem.