Skip to content
This repository has been archived by the owner on Jun 25, 2024. It is now read-only.

output of generator should be a tuple (x, y, sample_weight) or (x, y). Found: None #156

Open
zxt001 opened this issue Sep 4, 2019 · 0 comments

Comments

@zxt001
Copy link

zxt001 commented Sep 4, 2019

这段代码:
gen = Generator(gt, bbox_util, 16, path_prefix,
train_keys, val_keys,
(input_shape[0], input_shape[1]), do_crop=False)
batch_X = np.array(gen)
print(batch_X.shape)
打印为(),
报错如下:
This may consume a large amount of memory.
"Converting sparse IndexedSlices to a dense Tensor of unknown shape. "
Epoch 1/30
Traceback (most recent call last):
File "/datashare/h2410628/AXI/env_AXI/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1278, in _do_call
return fn(*args)
File "/datashare/h2410628/AXI/env_AXI/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1263, in _run_fn
options, feed_dict, fetch_list, target_list, run_metadata)
File "/datashare/h2410628/AXI/env_AXI/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1350, in _call_tf_sessionrun
run_metadata)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Incompatible shapes: [16,7308,4] vs. [16,28461,4]
[[Node: sub_2 = Sub[T=DT_FLOAT, _class=["loc:@gradients/AddN_1"], _device="/job:localhost/replica:0/task:0/device:GPU:0"](strided_slice_20, strided_slice_21)]]
[[Node: mul_11/_345 = _Recvclient_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_4411_mul_11", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "129_train.py", line 258, in
nb_worker=1)
File "/datashare/h2410628/AXI/env_AXI/lib/python3.5/site-packages/keras/engine/training.py", line 1557, in fit_generator
class_weight=class_weight)
File "/datashare/h2410628/AXI/env_AXI/lib/python3.5/site-packages/keras/engine/training.py", line 1320, in train_on_batch
outputs = self.train_function(ins)
File "/datashare/h2410628/AXI/env_AXI/lib/python3.5/site-packages/keras/backend/tensorflow_backend.py", line 1943, in call
feed_dict=feed_dict)
File "/datashare/h2410628/AXI/env_AXI/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 877, in run
run_metadata_ptr)
File "/datashare/h2410628/AXI/env_AXI/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1100, in _run
feed_dict_tensor, options, run_metadata)
File "/datashare/h2410628/AXI/env_AXI/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1272, in _do_run
run_metadata)
File "/datashare/h2410628/AXI/env_AXI/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1291, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Incompatible shapes: [16,7308,4] vs. [16,28461,4]
[[Node: sub_2 = Sub[T=DT_FLOAT, _class=["loc:@gradients/AddN_1"], _device="/job:localhost/replica:0/task:0/device:GPU:0"](strided_slice_20, strided_slice_21)]]
[[Node: mul_11/_345 = _Recvclient_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_4411_mul_11", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"]]

Caused by op 'sub_2', defined at:
File "129_train.py", line 251, in
loss=MultiboxLoss(NUM_CLASSES, neg_pos_ratio=2.0).compute_loss)
File "/datashare/h2410628/AXI/env_AXI/lib/python3.5/site-packages/keras/engine/training.py", line 667, in compile
sample_weight, mask)
File "/datashare/h2410628/AXI/env_AXI/lib/python3.5/site-packages/keras/engine/training.py", line 318, in weighted
score_array = fn(y_true, y_pred)
File "/datashare/h2410628/ObjectDetection/ssd/ssd_keras-02/loss.py", line 96, in compute_loss
y_pred[:, :, :4])
File "/datashare/h2410628/ObjectDetection/ssd/ssd_keras-02/loss.py", line 52, in _l1_smooth_loss
sq_loss = 0.5 * (y_true - y_pred)**2
File "/datashare/h2410628/AXI/env_AXI/lib/python3.5/site-packages/tensorflow/python/ops/math_ops.py", line 850, in binary_op_wrapper
return func(x, y, name=name)
File "/datashare/h2410628/AXI/env_AXI/lib/python3.5/site-packages/tensorflow/python/ops/gen_math_ops.py", line 8188, in sub
"Sub", x=x, y=y, name=name)
File "/datashare/h2410628/AXI/env_AXI/lib/python3.5/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
op_def=op_def)
File "/datashare/h2410628/AXI/env_AXI/lib/python3.5/site-packages/tensorflow/python/util/deprecation.py", line 454, in new_func
return func(*args, **kwargs)
File "/datashare/h2410628/AXI/env_AXI/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 3155, in create_op
op_def=op_def)
File "/datashare/h2410628/AXI/env_AXI/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 1717, in init
self._traceback = tf_stack.extract_stack()

InvalidArgumentError (see above for traceback): Incompatible shapes: [16,7308,4] vs. [16,28461,4]
[[Node: sub_2 = Sub[T=DT_FLOAT, _class=["loc:@gradients/AddN_1"], _device="/job:localhost/replica:0/task:0/device:GPU:0"](strided_slice_20, strided_slice_21)]]
[[Node: mul_11/_345 = _Recvclient_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_4411_mul_11", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"]]

我该怎么解决这个bug?

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

No branches or pull requests

1 participant