Skip to content
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

ValueError: Tensor conversion requested dtype int32 for Tensor with dtype float64: 'Tensor("strided_slice_2/stack_1:0", dtype=float64)' #27

Open
omrishsu opened this issue Aug 24, 2019 · 4 comments

Comments

@omrishsu
Copy link

I'm running the code with python 3.6 (fixed the print syntax errors) and added a utf-8 encoding when reading the dataset (I mention this since it maybe relevant).
When i try to run the code i get:
Traceback (most recent call last):
File "C:\Users\pc\AppData\Roaming\Python\Python35\site-packages\tensorflow\python\framework\op_def_library.py", line 510, in _apply_op_helper
preferred_dtype=default_dtype)
File "C:\Users\pc\AppData\Roaming\Python\Python35\site-packages\tensorflow\python\framework\ops.py", line 1022, in internal_convert_to_tensor
ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
File "C:\Users\pc\AppData\Roaming\Python\Python35\site-packages\tensorflow\python\framework\ops.py", line 866, in _TensorTensorConversionFunction
(dtype.name, t.dtype.name, str(t)))
ValueError: Tensor conversion requested dtype int32 for Tensor with dtype float64: 'Tensor("strided_slice_2/stack_1:0", dtype=float64)'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:\language-style-transfer\code\style_transfer.py", line 228, in
model = create_model(sess, args, vocab)
File "D:\language-style-transfer\code\style_transfer.py", line 192, in create_model
model = Model(args, vocab)
File "D:\language-style-transfer\code\style_transfer.py", line 120, in init
zeros, ones = self.labels[:half], self.labels[half:]
File "C:\Users\pc\AppData\Roaming\Python\Python35\site-packages\tensorflow\python\ops\array_ops.py", line 573, in _slice_helper
name=name)
File "C:\Users\pc\AppData\Roaming\Python\Python35\site-packages\tensorflow\python\ops\array_ops.py", line 737, in strided_slice
shrink_axis_mask=shrink_axis_mask)
File "C:\Users\pc\AppData\Roaming\Python\Python35\site-packages\tensorflow\python\ops\gen_array_ops.py", line 7407, in strided_slice
name=name)
File "C:\Users\pc\AppData\Roaming\Python\Python35\site-packages\tensorflow\python\framework\op_def_library.py", line 546, in _apply_op_helper
inferred_from[input_arg.type_attr]))
TypeError: Input 'end' of 'StridedSlice' Op has type float64 that does not match type int32 of argument 'begin'.

@omrishsu
Copy link
Author

I was able to solve it by changing
half = self.batch_size / 2
to
half = tf.cast((self.batch_size / 2),tf.int32)

@n0obcoder
Copy link

n0obcoder commented Apr 22, 2020

I was able to solve it by changing
half = self.batch_size / 2
to
half = tf.cast((self.batch_size / 2),tf.int32)

in which file ? @omrivm

@omrishsu
Copy link
Author

style_transfer.py

@n0obcoder
Copy link

@omrivm yes i found that already . But i appreciate you replying back in no time ! : D
Cheers ! : )

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