language-style-transfer icon indicating copy to clipboard operation
language-style-transfer copied to clipboard

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

Open omrishsu opened this issue 4 years ago • 4 comments

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 avatar Aug 24 '19 13:08 omrishsu

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

omrishsu avatar Aug 24 '19 16:08 omrishsu

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

n0obcoder avatar Apr 22 '20 12:04 n0obcoder

style_transfer.py

omrishsu avatar Apr 22 '20 13:04 omrishsu

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

n0obcoder avatar Apr 22 '20 13:04 n0obcoder