Repository: magenta/magenta

Issue:
TypeError: __init__() got multiple values for keyword argument 'dtype'
When I run the following command:
```
image_stylization_transform \
    --num_styles=10 \
    --checkpoint=multistyle-pastiche-generator-monet.ckpt \
    --input_image=1.jpg \
    --which_styles="{0:0.1,1:0.1,2:0.1,3:0.1,4:0.1,5:0.1,6:0.1,7:0.1,8:0.1,9:0.1}" \
    --output_dir=/tmp/image_stylization/output \
    --output_basename="all_monet_styles"
```
I get the following error:
```
Traceback (most recent call last):
  File "/home/ts/anaconda3/envs/py2/bin/image_stylization_transform", line 11, in <module>
    sys.exit(console_entry_point())
  File "/home/ts/anaconda3/envs/py2/lib/python2.7/site-packages/magenta/models/image_stylization/image_stylization_transform.py", line 144, in console_entry_point
    tf.app.run(main)
  File "/home/ts/anaconda3/envs/py2/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 44, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File "/home/ts/anaconda3/envs/py2/lib/python2.7/site-packages/magenta/models/image_stylization/image_stylization_transform.py", line 137, in main
    _multiple_styles(image, which_styles, output_dir)
  File "/home/ts/anaconda3/envs/py2/lib/python2.7/site-packages/magenta/models/image_stylization/image_stylization_transform.py", line 114, in _multiple_styles
    'scale': True})
  File "/home/ts/anaconda3/envs/py2/lib/python2.7/site-packages/magenta/models/image_stylization/model.py", line 54, in transform
    h = _conv2d(input_, 9, 1, 32, 'conv1')
  File "/home/ts/anaconda3/envs/py2/lib/python2.7/site-packages/magenta/models/image_stylization/model.py", line 102, in _conv2d
    scope=scope)
  File "/home/ts/anaconda3/envs/py2/lib/python2.7/site-packages/tensorflow/contrib/framework/python/ops/arg_scope.py", line 177, in func_with_args
    return func(*args, **current_args)
  File "/home/ts/anaconda3/envs/py2/lib/python2.7/site-packages/tensorflow/contrib/layers/python/layers/layers.py", line 916, in convolution
    outputs = normalizer_fn(outputs, **normalizer_params)
  File "/home/ts/anaconda3/envs/py2/lib/python2.7/site-packages/tensorflow/contrib/framework/python/ops/arg_scope.py", line 177, in func_with_args
    return func(*args, **current_args)
  File "/home/ts/anaconda3/envs/py2/lib/python2.7/site-packages/magenta/models/image_stylization/ops.py", line 204, in weighted_instance_norm
    'beta', tf.zeros_initializer, weights, num_categories)
  File "/home/ts/anaconda3/envs/py2/lib/python2.7/site-packages/magenta/models/image_stylization/ops.py", line 191, in _weighted_variable
    trainable=trainable)
  File "/home/ts/anaconda3/envs/py2/lib/python2.7/site-packages/tensorflow/contrib/framework/python/ops/arg_scope.py", line 177, in func_with_args
    return func(*args, **current_args)
  File "/home/ts/anaconda3/envs/py2/lib/python2.7/site-packages/tensorflow/contrib/framework/python/ops/variables.py", line 268, in model_variable
    partitioner=partitioner, custom_getter=custom_getter)
  File "/home/ts/anaconda3/envs/py2/lib/python2.7/site-packages/tensorflow/contrib/framework/python/ops/arg_scope.py", line 177, in func_with_args
    return func(*args, **current_args)
  File "/home/ts/anaconda3/envs/py2/lib/python2.7/site-packages/tensorflow/contrib/framework/python/ops/variables.py", line 225, in variable
    partitioner=partitioner)
  File "/home/ts/anaconda3/envs/py2/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 988, in get_variable
    custom_getter=custom_getter)
  File "/home/ts/anaconda3/envs/py2/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 890, in get_variable
    custom_getter=custom_getter)
  File "/home/ts/anaconda3/envs/py2/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 341, in get_variable
    validate_shape=validate_shape)
  File "/home/ts/anaconda3/envs/py2/lib/python2.7/site-packages/tensorflow/contrib/layers/python/layers/layers.py", line 1310, in layer_variable_getter
    return _model_variable_getter(getter, *args, **kwargs)
  File "/home/ts/anaconda3/envs/py2/lib/python2.7/site-packages/tensorflow/contrib/layers/python/layers/layers.py", line 1299, in _model_variable_getter
    custom_getter=getter)
  File "/home/ts/anaconda3/envs/py2/lib/python2.7/site-packages/tensorflow/contrib/framework/python/ops/arg_scope.py", line 177, in func_with_args
    return func(*args, **current_args)
  File "/home/ts/anaconda3/envs/py2/lib/python2.7/site-packages/tensorflow/contrib/framework/python/ops/variables.py", line 268, in model_variable
    partitioner=partitioner, custom_getter=custom_getter)
  File "/home/ts/anaconda3/envs/py2/lib/python2.7/site-packages/tensorflow/contrib/framework/python/ops/arg_scope.py", line 177, in func_with_args
    return func(*args, **current_args)
  File "/home/ts/anaconda3/envs/py2/lib/python2.7/site-packages/tensorflow/contrib/framework/python/ops/variables.py", line 225, in variable
    partitioner=partitioner)
  File "/home/ts/anaconda3/envs/py2/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 333, in _true_getter
    caching_device=caching_device, validate_shape=validate_shape)
  File "/home/ts/anaconda3/envs/py2/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 684, in _get_single_variable
    validate_shape=validate_shape)
  File "/home/ts/anaconda3/envs/py2/lib/python2.7/site-packages/tensorflow/python/ops/variables.py", line 226, in __init__
    expected_shape=expected_shape)
  File "/home/ts/anaconda3/envs/py2/lib/python2.7/site-packages/tensorflow/python/ops/variables.py", line 303, in _init_from_args
    initial_value(), name="initial_value", dtype=dtype)
  File "/home/ts/anaconda3/envs/py2/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 673, in <lambda>
    shape.as_list(), dtype=dtype, partition_info=partition_info)
TypeError: __init__() got multiple values for keyword argument 'dtype'
```

My tensorflow version is 1.0.0 which was compiled from the source.


Discussion:
I'm facing the same issue even after #535 
I'm using tensorflow 1.0.0 for gpu installed via pip.
Any leads would be appreciated.
@nikhilweee 
I found that the pip version isn't the latest version, maybe we should manually install it...
@EncodeTS: But what does pip have to do with it? I have the magenta repo cloned locally and also Tensorflow was installed via a URL. Neither of these depend on pip. Am I missing something here?
@nikhilweee I installed magenta with `pip install magenta`, and I found that on this [pypi site](https://pypi.python.org/pypi/magenta) the update date is "2017-01-27", so the pip version doesn't include the latest fix. But at this moment I don't know how to manully install the latest version, how do you install magenta?
I ran into the same problem, and it turns out the #535 fix was incomplete. This patch fixes it for the dict based styles:

```
--- a/magenta/models/image_stylization/ops.py
+++ b/magenta/models/image_stylization/ops.py
@@ -103,10 +103,10 @@ def conditional_instance_norm(inputs,
     beta, gamma = None, None
     if center:
       beta = _label_conditioned_variable(
-          'beta', tf.zeros_initializer, labels, num_categories)
+          'beta', tf.zeros_initializer(), labels, num_categories)
     if scale:
       gamma = _label_conditioned_variable(
```

Resolving patch:
diff --git a/magenta/models/image_stylization/ops.py b/magenta/models/image_stylization/ops.py
--- a/magenta/models/image_stylization/ops.py
+++ b/magenta/models/image_stylization/ops.py
@@ -201,7 +201,7 @@ def _weighted_variable(name, initializer, weights, num_categories):
     beta, gamma = None, None
     if center:
       beta = _weighted_variable(
-          'beta', tf.zeros_initializer, weights, num_categories)
+          'beta', tf.zeros_initializer(), weights, num_categories)
     if scale:
       gamma = _weighted_variable(
           'gamma', tf.ones_initializer(), weights, num_categories)


Test patch: