How to fix type error using tensorflow data API for rejection samplingHow to determine a Python variable's type?Object detection error on tensorflow 1.0, Python3.5, Anaconda and WIndows10How to use Dataset API to read TFRecords file of lists of variant length?How to convert keras float predictions to int?Tensorflow error: ValueError: None values not supportedINFO:tensorflow:Error reported to CoordinatorTensorflow model as service gives errorValue Error Tensorflow While Loading the Machine Learning project in Djangotensorflow tf.maximum(0, x) returns errorValueError: Argument must be a dense tensor when using estimator.predict

How much cash can I safely carry into the USA and avoid civil forfeiture?

What route did the Hindenburg take when traveling from Germany to the U.S.?

What is the relationship between spectral sequences and obstruction theory?

How do I deal with a coworker that keeps asking to make small superficial changes to a report, and it is seriously triggering my anxiety?

Was there a shared-world project before "Thieves World"?

How can the Zone of Truth spell be defeated without the caster knowing?

What does it mean to express a gate in Dirac notation?

How come there are so many candidates for the 2020 Democratic party presidential nomination?

Fizzy, soft, pop and still drinks

How do I reattach a shelf to the wall when it ripped out of the wall?

How to type a section sign (§) into the Minecraft client

Is the 5 MB static resource size limit 5,242,880 bytes or 5,000,000 bytes?

Reducing vertical space in stackrel

French for 'It must be my imagination'?

How would one muzzle a full grown polar bear in the 13th century?

Does a semiconductor follow Ohm's law?

How to creep the reader out with what seems like a normal person?

Why do Computer Science majors learn Calculus?

Why does processed meat contain preservatives, while canned fish needs not?

How to have a sharp product image?

What does KSP mean?

Document starts having heaps of errors in the middle, but the code doesn't have any problems in it

Will a top journal at least read my introduction?

How did Captain America manage to do this?



How to fix type error using tensorflow data API for rejection sampling


How to determine a Python variable's type?Object detection error on tensorflow 1.0, Python3.5, Anaconda and WIndows10How to use Dataset API to read TFRecords file of lists of variant length?How to convert keras float predictions to int?Tensorflow error: ValueError: None values not supportedINFO:tensorflow:Error reported to CoordinatorTensorflow model as service gives errorValue Error Tensorflow While Loading the Machine Learning project in Djangotensorflow tf.maximum(0, x) returns errorValueError: Argument must be a dense tensor when using estimator.predict






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I am using the tensorflow data API to try and do some rejection sampling for my unbalanced data set.



I have run the code on my personal computer and it seems to work as I expect it to, however, when I run the code on my University's cluster I get a type error that I can't seem to understand. I have tried recasting and I get the same error.



I am still learning how to use this API and I'm still not 100% clear on if this is the best way to achieve what I want, so I also welcome any advice on how I implemented the rejection sampling (this could very well be the reason why I get error since I don't fully understand yet).



This is how I am loading in the data to the dataset:



data = np.loadtxt("my_data.dat")
features = data[:, 1:10]
labels = data[:, 0]
labels[labels == -1] = 0
assert features.shape[0] == labels.shape[0]
dataset_size = len(features)

dataset = tf.data.Dataset.from_tensor_slices((features.astype('float32'),
labels.astype('int32')))
dataset = dataset.shuffle(buffer_size=dataset_size)


the error occurs when I read here:



train_size = int((2/3.0)*dataset_size)
tr_dataset = dataset.take(train_size)
tr_dataset = (tr_dataset.apply(
tf.contrib.data.rejection_resample(
class_func=lambda _, c: c, target_dist=[0.5, 0.5],
seed=42)).map(lambda a, b: b)).batch(100)


This is the error:



Traceback (most recent call last):
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 510, in _apply_op_helper
preferred_dtype=default_dtype)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1094, in internal_convert_to_tensor
ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 931, in _TensorTensorConversionFunction
(dtype.name, t.dtype.name, str(t)))
ValueError: Tensor conversion requested dtype int32 for Tensor with dtype int64: 'Tensor("Sum:0", shape=(2,), dtype=int64)'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "test.py", line 185, in <module>
seed=42))).batch(100)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 1109, in apply
dataset = transformation_func(self)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/contrib/data/python/ops/resampling.py", line 74, in _apply_fn
target_dist_t, class_values_ds)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/contrib/data/python/ops/resampling.py", line 183, in _estimate_initial_dist_ds
update_estimate_and_tile))
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 1109, in apply
dataset = transformation_func(self)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/contrib/data/python/ops/scan_ops.py", line 172, in _apply_fn
return _ScanDataset(dataset, initial_state, scan_func)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/contrib/data/python/ops/scan_ops.py", line 74, in __init__
add_to_graph=False)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 1459, in __init__
self._function._create_definition_if_needed() # pylint: disable=protected-access
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/framework/function.py", line 337, in _create_definition_if_needed
self._create_definition_if_needed_impl()
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/framework/function.py", line 346, in _create_definition_if_needed_impl
self._capture_by_value, self._caller_device)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/framework/function.py", line 863, in func_graph_from_py_func
outputs = func(*func_graph.inputs)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 1392, in tf_data_structured_function_wrapper
ret = func(*nested_args)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/contrib/data/python/ops/resampling.py", line 176, in update_estimate_and_tile
c, num_examples_per_class_seen)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/contrib/data/python/ops/resampling.py", line 212, in _estimate_data_distribution
array_ops.one_hot(c, num_classes, dtype=dtypes.int64), 0))
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/ops/gen_math_ops.py", line 297, in add
"Add", x=x, y=y, name=name)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 546, in _apply_op_helper
inferred_from[input_arg.type_attr]))
TypeError: Input 'y' of 'Add' Op has type int64 that does not match type int32 of argument 'x'.









share|improve this question






















  • Does the versions of tf differ from your local and your cluster? And from line 176 and 212 of resample.py pointed out in your error trace, I think converting to int32 is the problem for the second exception.

    – kvish
    Mar 23 at 0:33











  • @kvish Yes, on my local its 1.13 and on my cluster its 1.10. I have tried not casting and I get the error that the only supported types are uint8, int32, int64. I have tried using the "other" supported types and I get the same error as in the post. I don't really know where to go from here

    – tinman248
    Mar 26 at 11:59











  • UPDATE: I have upgraded the tensorflow version on the cluster to 1.13 (the version on my local machine) and I get the same error...

    – tinman248
    Mar 26 at 12:28











  • this is very weird. Could this be an issue in the sense that you might need to pass dtype compatible with numpy or tf? As in you can use tf.cast to cast your data types, or use np.int32 etc?

    – kvish
    Mar 26 at 21:01

















0















I am using the tensorflow data API to try and do some rejection sampling for my unbalanced data set.



I have run the code on my personal computer and it seems to work as I expect it to, however, when I run the code on my University's cluster I get a type error that I can't seem to understand. I have tried recasting and I get the same error.



I am still learning how to use this API and I'm still not 100% clear on if this is the best way to achieve what I want, so I also welcome any advice on how I implemented the rejection sampling (this could very well be the reason why I get error since I don't fully understand yet).



This is how I am loading in the data to the dataset:



data = np.loadtxt("my_data.dat")
features = data[:, 1:10]
labels = data[:, 0]
labels[labels == -1] = 0
assert features.shape[0] == labels.shape[0]
dataset_size = len(features)

dataset = tf.data.Dataset.from_tensor_slices((features.astype('float32'),
labels.astype('int32')))
dataset = dataset.shuffle(buffer_size=dataset_size)


the error occurs when I read here:



train_size = int((2/3.0)*dataset_size)
tr_dataset = dataset.take(train_size)
tr_dataset = (tr_dataset.apply(
tf.contrib.data.rejection_resample(
class_func=lambda _, c: c, target_dist=[0.5, 0.5],
seed=42)).map(lambda a, b: b)).batch(100)


This is the error:



Traceback (most recent call last):
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 510, in _apply_op_helper
preferred_dtype=default_dtype)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1094, in internal_convert_to_tensor
ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 931, in _TensorTensorConversionFunction
(dtype.name, t.dtype.name, str(t)))
ValueError: Tensor conversion requested dtype int32 for Tensor with dtype int64: 'Tensor("Sum:0", shape=(2,), dtype=int64)'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "test.py", line 185, in <module>
seed=42))).batch(100)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 1109, in apply
dataset = transformation_func(self)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/contrib/data/python/ops/resampling.py", line 74, in _apply_fn
target_dist_t, class_values_ds)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/contrib/data/python/ops/resampling.py", line 183, in _estimate_initial_dist_ds
update_estimate_and_tile))
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 1109, in apply
dataset = transformation_func(self)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/contrib/data/python/ops/scan_ops.py", line 172, in _apply_fn
return _ScanDataset(dataset, initial_state, scan_func)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/contrib/data/python/ops/scan_ops.py", line 74, in __init__
add_to_graph=False)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 1459, in __init__
self._function._create_definition_if_needed() # pylint: disable=protected-access
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/framework/function.py", line 337, in _create_definition_if_needed
self._create_definition_if_needed_impl()
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/framework/function.py", line 346, in _create_definition_if_needed_impl
self._capture_by_value, self._caller_device)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/framework/function.py", line 863, in func_graph_from_py_func
outputs = func(*func_graph.inputs)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 1392, in tf_data_structured_function_wrapper
ret = func(*nested_args)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/contrib/data/python/ops/resampling.py", line 176, in update_estimate_and_tile
c, num_examples_per_class_seen)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/contrib/data/python/ops/resampling.py", line 212, in _estimate_data_distribution
array_ops.one_hot(c, num_classes, dtype=dtypes.int64), 0))
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/ops/gen_math_ops.py", line 297, in add
"Add", x=x, y=y, name=name)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 546, in _apply_op_helper
inferred_from[input_arg.type_attr]))
TypeError: Input 'y' of 'Add' Op has type int64 that does not match type int32 of argument 'x'.









share|improve this question






















  • Does the versions of tf differ from your local and your cluster? And from line 176 and 212 of resample.py pointed out in your error trace, I think converting to int32 is the problem for the second exception.

    – kvish
    Mar 23 at 0:33











  • @kvish Yes, on my local its 1.13 and on my cluster its 1.10. I have tried not casting and I get the error that the only supported types are uint8, int32, int64. I have tried using the "other" supported types and I get the same error as in the post. I don't really know where to go from here

    – tinman248
    Mar 26 at 11:59











  • UPDATE: I have upgraded the tensorflow version on the cluster to 1.13 (the version on my local machine) and I get the same error...

    – tinman248
    Mar 26 at 12:28











  • this is very weird. Could this be an issue in the sense that you might need to pass dtype compatible with numpy or tf? As in you can use tf.cast to cast your data types, or use np.int32 etc?

    – kvish
    Mar 26 at 21:01













0












0








0








I am using the tensorflow data API to try and do some rejection sampling for my unbalanced data set.



I have run the code on my personal computer and it seems to work as I expect it to, however, when I run the code on my University's cluster I get a type error that I can't seem to understand. I have tried recasting and I get the same error.



I am still learning how to use this API and I'm still not 100% clear on if this is the best way to achieve what I want, so I also welcome any advice on how I implemented the rejection sampling (this could very well be the reason why I get error since I don't fully understand yet).



This is how I am loading in the data to the dataset:



data = np.loadtxt("my_data.dat")
features = data[:, 1:10]
labels = data[:, 0]
labels[labels == -1] = 0
assert features.shape[0] == labels.shape[0]
dataset_size = len(features)

dataset = tf.data.Dataset.from_tensor_slices((features.astype('float32'),
labels.astype('int32')))
dataset = dataset.shuffle(buffer_size=dataset_size)


the error occurs when I read here:



train_size = int((2/3.0)*dataset_size)
tr_dataset = dataset.take(train_size)
tr_dataset = (tr_dataset.apply(
tf.contrib.data.rejection_resample(
class_func=lambda _, c: c, target_dist=[0.5, 0.5],
seed=42)).map(lambda a, b: b)).batch(100)


This is the error:



Traceback (most recent call last):
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 510, in _apply_op_helper
preferred_dtype=default_dtype)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1094, in internal_convert_to_tensor
ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 931, in _TensorTensorConversionFunction
(dtype.name, t.dtype.name, str(t)))
ValueError: Tensor conversion requested dtype int32 for Tensor with dtype int64: 'Tensor("Sum:0", shape=(2,), dtype=int64)'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "test.py", line 185, in <module>
seed=42))).batch(100)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 1109, in apply
dataset = transformation_func(self)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/contrib/data/python/ops/resampling.py", line 74, in _apply_fn
target_dist_t, class_values_ds)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/contrib/data/python/ops/resampling.py", line 183, in _estimate_initial_dist_ds
update_estimate_and_tile))
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 1109, in apply
dataset = transformation_func(self)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/contrib/data/python/ops/scan_ops.py", line 172, in _apply_fn
return _ScanDataset(dataset, initial_state, scan_func)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/contrib/data/python/ops/scan_ops.py", line 74, in __init__
add_to_graph=False)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 1459, in __init__
self._function._create_definition_if_needed() # pylint: disable=protected-access
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/framework/function.py", line 337, in _create_definition_if_needed
self._create_definition_if_needed_impl()
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/framework/function.py", line 346, in _create_definition_if_needed_impl
self._capture_by_value, self._caller_device)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/framework/function.py", line 863, in func_graph_from_py_func
outputs = func(*func_graph.inputs)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 1392, in tf_data_structured_function_wrapper
ret = func(*nested_args)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/contrib/data/python/ops/resampling.py", line 176, in update_estimate_and_tile
c, num_examples_per_class_seen)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/contrib/data/python/ops/resampling.py", line 212, in _estimate_data_distribution
array_ops.one_hot(c, num_classes, dtype=dtypes.int64), 0))
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/ops/gen_math_ops.py", line 297, in add
"Add", x=x, y=y, name=name)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 546, in _apply_op_helper
inferred_from[input_arg.type_attr]))
TypeError: Input 'y' of 'Add' Op has type int64 that does not match type int32 of argument 'x'.









share|improve this question














I am using the tensorflow data API to try and do some rejection sampling for my unbalanced data set.



I have run the code on my personal computer and it seems to work as I expect it to, however, when I run the code on my University's cluster I get a type error that I can't seem to understand. I have tried recasting and I get the same error.



I am still learning how to use this API and I'm still not 100% clear on if this is the best way to achieve what I want, so I also welcome any advice on how I implemented the rejection sampling (this could very well be the reason why I get error since I don't fully understand yet).



This is how I am loading in the data to the dataset:



data = np.loadtxt("my_data.dat")
features = data[:, 1:10]
labels = data[:, 0]
labels[labels == -1] = 0
assert features.shape[0] == labels.shape[0]
dataset_size = len(features)

dataset = tf.data.Dataset.from_tensor_slices((features.astype('float32'),
labels.astype('int32')))
dataset = dataset.shuffle(buffer_size=dataset_size)


the error occurs when I read here:



train_size = int((2/3.0)*dataset_size)
tr_dataset = dataset.take(train_size)
tr_dataset = (tr_dataset.apply(
tf.contrib.data.rejection_resample(
class_func=lambda _, c: c, target_dist=[0.5, 0.5],
seed=42)).map(lambda a, b: b)).batch(100)


This is the error:



Traceback (most recent call last):
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 510, in _apply_op_helper
preferred_dtype=default_dtype)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1094, in internal_convert_to_tensor
ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 931, in _TensorTensorConversionFunction
(dtype.name, t.dtype.name, str(t)))
ValueError: Tensor conversion requested dtype int32 for Tensor with dtype int64: 'Tensor("Sum:0", shape=(2,), dtype=int64)'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "test.py", line 185, in <module>
seed=42))).batch(100)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 1109, in apply
dataset = transformation_func(self)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/contrib/data/python/ops/resampling.py", line 74, in _apply_fn
target_dist_t, class_values_ds)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/contrib/data/python/ops/resampling.py", line 183, in _estimate_initial_dist_ds
update_estimate_and_tile))
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 1109, in apply
dataset = transformation_func(self)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/contrib/data/python/ops/scan_ops.py", line 172, in _apply_fn
return _ScanDataset(dataset, initial_state, scan_func)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/contrib/data/python/ops/scan_ops.py", line 74, in __init__
add_to_graph=False)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 1459, in __init__
self._function._create_definition_if_needed() # pylint: disable=protected-access
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/framework/function.py", line 337, in _create_definition_if_needed
self._create_definition_if_needed_impl()
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/framework/function.py", line 346, in _create_definition_if_needed_impl
self._capture_by_value, self._caller_device)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/framework/function.py", line 863, in func_graph_from_py_func
outputs = func(*func_graph.inputs)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 1392, in tf_data_structured_function_wrapper
ret = func(*nested_args)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/contrib/data/python/ops/resampling.py", line 176, in update_estimate_and_tile
c, num_examples_per_class_seen)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/contrib/data/python/ops/resampling.py", line 212, in _estimate_data_distribution
array_ops.one_hot(c, num_classes, dtype=dtypes.int64), 0))
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/ops/gen_math_ops.py", line 297, in add
"Add", x=x, y=y, name=name)
File "/home/user/.conda/envs/tensorflowcpu/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 546, in _apply_op_helper
inferred_from[input_arg.type_attr]))
TypeError: Input 'y' of 'Add' Op has type int64 that does not match type int32 of argument 'x'.






python tensorflow types tensor tensorflow-datasets






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 22 at 18:21









tinman248tinman248

10318




10318












  • Does the versions of tf differ from your local and your cluster? And from line 176 and 212 of resample.py pointed out in your error trace, I think converting to int32 is the problem for the second exception.

    – kvish
    Mar 23 at 0:33











  • @kvish Yes, on my local its 1.13 and on my cluster its 1.10. I have tried not casting and I get the error that the only supported types are uint8, int32, int64. I have tried using the "other" supported types and I get the same error as in the post. I don't really know where to go from here

    – tinman248
    Mar 26 at 11:59











  • UPDATE: I have upgraded the tensorflow version on the cluster to 1.13 (the version on my local machine) and I get the same error...

    – tinman248
    Mar 26 at 12:28











  • this is very weird. Could this be an issue in the sense that you might need to pass dtype compatible with numpy or tf? As in you can use tf.cast to cast your data types, or use np.int32 etc?

    – kvish
    Mar 26 at 21:01

















  • Does the versions of tf differ from your local and your cluster? And from line 176 and 212 of resample.py pointed out in your error trace, I think converting to int32 is the problem for the second exception.

    – kvish
    Mar 23 at 0:33











  • @kvish Yes, on my local its 1.13 and on my cluster its 1.10. I have tried not casting and I get the error that the only supported types are uint8, int32, int64. I have tried using the "other" supported types and I get the same error as in the post. I don't really know where to go from here

    – tinman248
    Mar 26 at 11:59











  • UPDATE: I have upgraded the tensorflow version on the cluster to 1.13 (the version on my local machine) and I get the same error...

    – tinman248
    Mar 26 at 12:28











  • this is very weird. Could this be an issue in the sense that you might need to pass dtype compatible with numpy or tf? As in you can use tf.cast to cast your data types, or use np.int32 etc?

    – kvish
    Mar 26 at 21:01
















Does the versions of tf differ from your local and your cluster? And from line 176 and 212 of resample.py pointed out in your error trace, I think converting to int32 is the problem for the second exception.

– kvish
Mar 23 at 0:33





Does the versions of tf differ from your local and your cluster? And from line 176 and 212 of resample.py pointed out in your error trace, I think converting to int32 is the problem for the second exception.

– kvish
Mar 23 at 0:33













@kvish Yes, on my local its 1.13 and on my cluster its 1.10. I have tried not casting and I get the error that the only supported types are uint8, int32, int64. I have tried using the "other" supported types and I get the same error as in the post. I don't really know where to go from here

– tinman248
Mar 26 at 11:59





@kvish Yes, on my local its 1.13 and on my cluster its 1.10. I have tried not casting and I get the error that the only supported types are uint8, int32, int64. I have tried using the "other" supported types and I get the same error as in the post. I don't really know where to go from here

– tinman248
Mar 26 at 11:59













UPDATE: I have upgraded the tensorflow version on the cluster to 1.13 (the version on my local machine) and I get the same error...

– tinman248
Mar 26 at 12:28





UPDATE: I have upgraded the tensorflow version on the cluster to 1.13 (the version on my local machine) and I get the same error...

– tinman248
Mar 26 at 12:28













this is very weird. Could this be an issue in the sense that you might need to pass dtype compatible with numpy or tf? As in you can use tf.cast to cast your data types, or use np.int32 etc?

– kvish
Mar 26 at 21:01





this is very weird. Could this be an issue in the sense that you might need to pass dtype compatible with numpy or tf? As in you can use tf.cast to cast your data types, or use np.int32 etc?

– kvish
Mar 26 at 21:01












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55305702%2fhow-to-fix-type-error-using-tensorflow-data-api-for-rejection-sampling%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55305702%2fhow-to-fix-type-error-using-tensorflow-data-api-for-rejection-sampling%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript