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 float32: <tf.Tensor 'shuffle_batch/sub/y:0' shape=() dtype=float32> #16

Open
HaFred opened this issue Nov 12, 2020 · 0 comments

Comments

@HaFred
Copy link

HaFred commented Nov 12, 2020

When I tried to run the Top.py, exceptions are shown as below:

2020-11-12 03:39:21 

import time
import tensorflow as tf

debug = False
Time = time.strftime('%Y-%m-%d', time.localtime())
# Notes = 'vgg7 2888'
Notes = 'temp'

GPU = [0]
batchSize = 128

dataSet = 'CIFAR10'

loadModel = None
# loadModel = '../model/' + '2017-12-06' + '(' + 'vgg7 2888' + ')' + '.tf'
saveModel = None
# saveModel = '../model/' + Time + '(' + Notes + ')' + '.tf'

bitsW = 2  # bit width of we ights
bitsA = 8  # bit width of activations
bitsG = 8  # bit width of gradients
bitsE = 8  # bit width of errors

bitsR = 16  # bit width of randomizer

lr = tf.Variable(initial_value=0., trainable=False, name='lr', dtype=tf.float32)
lr_schedule = [0, 8, 200, 1,250,1./8,300,0]

L2 = 0

lossFunc = 'SSE'
# lossFunc = tf.losses.softmax_cross_entropy
optimizer = tf.compat.v1.train.GradientDescentOptimizer(1)  # lr is controlled in Quantize.G
# optimizer = tf.train.MomentumOptimizer(lr, 0.9, use_nesterov=True)

# shared variables, defined by other files
seed = None
sess = None
W_scale = []

WARNING:tensorflow:From /content/drive/My Drive/workspace/wage/source/getData.py:46: The name tf.FIFOQueue is deprecated. Please use tf.queue.FIFOQueue instead.

WARNING:tensorflow:From /content/drive/My Drive/workspace/wage/source/getData.py:49: QueueRunner.__init__ (from tensorflow.python.training.queue_runner_impl) is deprecated and will be removed in a future version.
Instructions for updating:
To construct input pipelines, use the `tf.data` module.
WARNING:tensorflow:From /content/drive/My Drive/workspace/wage/source/getData.py:50: add_queue_runner (from tensorflow.python.training.queue_runner_impl) is deprecated and will be removed in a future version.
Instructions for updating:
To construct input pipelines, use the `tf.data` module.
WARNING:tensorflow:From /content/drive/My Drive/workspace/wage/source/getData.py:9: The name tf.image.resize_image_with_crop_or_pad is deprecated. Please use tf.image.resize_with_crop_or_pad instead.

WARNING:tensorflow:From /content/drive/My Drive/workspace/wage/source/getData.py:10: The name tf.random_crop is deprecated. Please use tf.image.random_crop instead.

WARNING:tensorflow:From /content/drive/My Drive/workspace/wage/source/getData.py:59: shuffle_batch (from tensorflow.python.training.input) is deprecated and will be removed in a future version.
Instructions for updating:
Queue-based input pipelines have been replaced by `tf.data`. Use `tf.data.Dataset.shuffle(min_after_dequeue).batch(batch_size)`.
Traceback (most recent call last):
  File "/tensorflow-1.15.2/python3.6/tensorflow_core/python/framework/op_def_library.py", line 528, in _apply_op_helper
    preferred_dtype=default_dtype)
  File "/tensorflow-1.15.2/python3.6/tensorflow_core/python/framework/ops.py", line 1273, in internal_convert_to_tensor
    (dtype.name, value.dtype.name, value))
ValueError: Tensor conversion requested dtype int32 for Tensor with dtype float32: <tf.Tensor 'shuffle_batch/sub/y:0' shape=() dtype=float32>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "Top.py", line 167, in <module>
    main()
  File "Top.py", line 47, in main
    getData.loadData(Option.dataSet,batchSize,numThread)
  File "/content/drive/My Drive/workspace/wage/source/getData.py", line 25, in loadData
    trainX, trainY = data2Queue(numpyTrainX, numpyTrainY, batchSize,numThread, True,True)
  File "/content/drive/My Drive/workspace/wage/source/getData.py", line 59, in data2Queue
    seed=seed)
  File "/tensorflow-1.15.2/python3.6/tensorflow_core/python/util/deprecation.py", line 324, in new_func
    return func(*args, **kwargs)
  File "/tensorflow-1.15.2/python3.6/tensorflow_core/python/training/input.py", line 1347, in shuffle_batch
    name=name)
  File "/tensorflow-1.15.2/python3.6/tensorflow_core/python/training/input.py", line 862, in _shuffle_batch
    math_ops.maximum(0, queue.size() - min_after_dequeue), dtypes.float32) *
  File "/tensorflow-1.15.2/python3.6/tensorflow_core/python/ops/math_ops.py", line 912, in binary_op_wrapper
    return func(x, y, name=name)
  File "/tensorflow-1.15.2/python3.6/tensorflow_core/python/ops/gen_math_ops.py", line 11086, in sub
    "Sub", x=x, y=y, name=name)
  File "/tensorflow-1.15.2/python3.6/tensorflow_core/python/framework/op_def_library.py", line 564, in _apply_op_helper
    inferred_from[input_arg.type_attr]))
TypeError: Input 'y' of 'Sub' Op has type float32 that does not match type int32 of argument 'x'.
Exception ignored in: <Log.Log object at 0x7f5a34dfeba8>
AttributeError: 'Log' object has no attribute 'flush'
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

1 participant