Skip to content

It seems impossible to generate with scalar_input on? #291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
carykh opened this issue Sep 9, 2017 · 2 comments
Open

It seems impossible to generate with scalar_input on? #291

carykh opened this issue Sep 9, 2017 · 2 comments

Comments

@carykh
Copy link

carykh commented Sep 9, 2017

The two options for inputs are scalar and one-hot, with one-hot being the default, right?

If I set the parameters in wavenet_params.json to use scalar, the network trains just fine. But when I try to generate, it says "Incremental generation does not support scalar input yet." That seems fair enough. It looks like the easiest solution to this is to turn off "fast_generation", which will call the function predict_proba instead of predict_proba_incremental. However, when I do that, I get this error:

ValueError: Shape must be rank 4 but is rank 3 for 'wavenet_1/causal_layer/causal_conv/conv1d/Conv2D' (op: 'Conv2D') with input shapes: [?,1,1], [1,32,1,32].

This kinda makes sense to me, because a scalar has one fewer dimension than a one-hot vector, so I could understand why the resulting tensor's shape now has 3 dimensions instead of 4. However, when I tried reshaping the tensor to have 4 dimensions, I still couldn't get it to work. I don't think I understand TensorFlow or this code closely enough to fix this problem. Help!

@carykh
Copy link
Author

carykh commented Sep 9, 2017

Maybe it's helpful if I include the stack output?

Restoring model from /media/rob/Ma Book/WAVENET_DUMP/DUMP8/model.ckpt-600
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 1327, in _do_call
    return fn(*args)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 1306, in _run_fn
    status, run_metadata)
  File "/usr/lib/python3.5/contextlib.py", line 66, in __exit__
    next(self.gen)
  File "/usr/local/lib/python3.5/dist-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: Expected begin[1] in [0, 1275], but got 2580
	 [[Node: wavenet_1/dilated_stack/layer0/Slice = Slice[Index=DT_INT32, T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/gpu:0"](wavenet_1/dilated_stack/layer0/mul, wavenet_1/dilated_stack/layer0/Slice/begin, wavenet_1/dilated_stack/layer0/Slice/size)]]
	 [[Node: wavenet_1/Reshape_3/_653 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/gpu:0", send_device_incarnation=1, tensor_name="edge_15056_wavenet_1/Reshape_3", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"]()]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "generate.py", line 287, in <module>
    main()
  File "generate.py", line 226, in main
    prediction = sess.run(outputs, feed_dict={samples: window})[0]
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 895, in run
    run_metadata_ptr)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 1124, in _run
    feed_dict_tensor, options, run_metadata)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 1321, in _do_run
    options, run_metadata)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 1340, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Expected begin[1] in [0, 1275], but got 2580
	 [[Node: wavenet_1/dilated_stack/layer0/Slice = Slice[Index=DT_INT32, T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/gpu:0"](wavenet_1/dilated_stack/layer0/mul, wavenet_1/dilated_stack/layer0/Slice/begin, wavenet_1/dilated_stack/layer0/Slice/size)]]
	 [[Node: wavenet_1/Reshape_3/_653 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/gpu:0", send_device_incarnation=1, tensor_name="edge_15056_wavenet_1/Reshape_3", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"]()]]

Caused by op 'wavenet_1/dilated_stack/layer0/Slice', defined at:
  File "generate.py", line 287, in <module>
    main()
  File "generate.py", line 164, in main
    next_sample = net.predict_proba(samples, args.gc_id)
  File "/home/rob/Documents/Python/tensorflow-ARSS-wavenet-master/wavenet/model.py", line 591, in predict_proba
    raw_output = self._create_network(encoded, gc_embedding)
  File "/home/rob/Documents/Python/tensorflow-ARSS-wavenet-master/wavenet/model.py", line 419, in _create_network
    global_condition_batch, output_width)
  File "/home/rob/Documents/Python/tensorflow-ARSS-wavenet-master/wavenet/model.py", line 310, in _create_dilation_layer
    out_skip = tf.slice(out, [0, skip_cut, 0], [-1, -1, -1])
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/ops/array_ops.py", line 561, in slice
    return gen_array_ops._slice(input_, begin, size, name=name)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/ops/gen_array_ops.py", line 3125, in _slice
    name=name)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/op_def_library.py", line 767, in apply_op
    op_def=op_def)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/ops.py", line 2630, in create_op
    original_op=self._default_original_op, op_def=op_def)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/ops.py", line 1204, in __init__
    self._traceback = self._graph._extract_stack()  # pylint: disable=protected-access

InvalidArgumentError (see above for traceback): Expected begin[1] in [0, 1275], but got 2580
	 [[Node: wavenet_1/dilated_stack/layer0/Slice = Slice[Index=DT_INT32, T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/gpu:0"](wavenet_1/dilated_stack/layer0/mul, wavenet_1/dilated_stack/layer0/Slice/begin, wavenet_1/dilated_stack/layer0/Slice/size)]]
	 [[Node: wavenet_1/Reshape_3/_653 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/gpu:0", send_device_incarnation=1, tensor_name="edge_15056_wavenet_1/Reshape_3", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"]()]]

@nsfinkelstein
Copy link

I ran into the same problem. I've submitted a PR for a fix here: #292

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants