ValueError:无法将大小为85的轴拆分为大小为[2,2,1,20]的keras训练 [英] ValueError: can't split axis of size 85 into pieces of size [2,2,1,20] keras training

查看:91
本文介绍了ValueError:无法将大小为85的轴拆分为大小为[2,2,1,20]的keras训练的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在培训开始时出现此错误,这是什么意思?没有明确说明导致错误的原因/问题的根源..................................... ................................................... ................................................... ........................

I got this error at the start of the training, what does it mean? there is no clear indication of what causes the error/the source of the problem ..............................................................................................................................................................

Epoch 1/10
Traceback (most recent call last):
  File "train.py", line 199, in <module>
    app.run(main)
  File "/usr/local/lib/python3.6/dist-packages/absl/app.py", line 299, in run
    _run_main(main, args)
  File "/usr/local/lib/python3.6/dist-packages/absl/app.py", line 250, in _run_main
    sys.exit(main(argv))
  File "train.py", line 194, in main
    validation_data=val_dataset)
  File "/root/.local/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py", line 71, in _method_wrapper
    return method(self, *args, **kwargs)
  File "/root/.local/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py", line 920, in fit
    tmp_logs = train_function(iterator)
  File "/root/.local/lib/python3.6/site-packages/tensorflow/python/eager/def_function.py", line 608, in __call__
    result = self._call(*args, **kwds)
  File "/root/.local/lib/python3.6/site-packages/tensorflow/python/eager/def_function.py", line 655, in _call
    self._initialize(args, kwds, add_initializers_to=initializers)
  File "/root/.local/lib/python3.6/site-packages/tensorflow/python/eager/def_function.py", line 535, in _initialize
    *args, **kwds))
  File "/root/.local/lib/python3.6/site-packages/tensorflow/python/eager/function.py", line 2447, in _get_concrete_function_internal_garbage_collected
    graph_function, _, _ = self._maybe_define_function(args, kwargs)
  File "/root/.local/lib/python3.6/site-packages/tensorflow/python/eager/function.py", line 2775, in _maybe_define_function
    graph_function = self._create_graph_function(args, kwargs)
  File "/root/.local/lib/python3.6/site-packages/tensorflow/python/eager/function.py", line 2665, in _create_graph_function
    capture_by_value=self._capture_by_value),
  File "/root/.local/lib/python3.6/site-packages/tensorflow/python/framework/func_graph.py", line 981, in func_graph_from_py_func
    func_outputs = python_func(*func_args, **func_kwargs)
  File "/root/.local/lib/python3.6/site-packages/tensorflow/python/eager/def_function.py", line 446, in wrapped_fn
    return weak_wrapped_fn().__wrapped__(*args, **kwds)
  File "/root/.local/lib/python3.6/site-packages/tensorflow/python/framework/func_graph.py", line 968, in wrapper
    raise e.ag_error_metadata.to_exception(e)
ValueError: in user code:

    /root/.local/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py:630 train_function  *
        return step_function(self, iterator)
    /root/.local/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py:620 step_function  **
        outputs = model.distribute_strategy.run(run_step, args=(data,))
    /root/.local/lib/python3.6/site-packages/tensorflow/python/distribute/distribute_lib.py:952 run
        return self._extended.call_for_each_replica(fn, args=args, kwargs=kwargs)
    /root/.local/lib/python3.6/site-packages/tensorflow/python/distribute/distribute_lib.py:2292 call_for_each_replica
        return self._call_for_each_replica(fn, args, kwargs)
    /root/.local/lib/python3.6/site-packages/tensorflow/python/distribute/distribute_lib.py:2651 _call_for_each_replica
        return fn(*args, **kwargs)
    /root/.local/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py:613 run_step  **
        outputs = model.train_step(data)
    /root/.local/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py:573 train_step
        y, y_pred, sample_weight, regularization_losses=self.losses)
    /root/.local/lib/python3.6/site-packages/tensorflow/python/keras/engine/compile_utils.py:204 __call__
        loss_value = loss_obj(y_t, y_p, sample_weight=sw)
    /root/.local/lib/python3.6/site-packages/tensorflow/python/keras/losses.py:145 __call__
        losses = self.call(y_true, y_pred)
    /root/.local/lib/python3.6/site-packages/tensorflow/python/keras/losses.py:248 call
        return self.fn(y_true, y_pred, **self._fn_kwargs)
    /content/drive/My Drive/yolov3-tf2/yolov3_tf2/models.py:264 yolo_loss
        y_pred, anchors, classes)
    /content/drive/My Drive/yolov3-tf2/yolov3_tf2/models.py:155 yolo_boxes
        pred, (2, 2, 1, classes), axis=-1)
    /root/.local/lib/python3.6/site-packages/tensorflow/python/ops/array_ops.py:1978 split
        value=value, size_splits=size_splits, axis=axis, num_split=num, name=name)
    /root/.local/lib/python3.6/site-packages/tensorflow/python/ops/gen_array_ops.py:9881 split_v
        num_split=num_split, name=name)
    /root/.local/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py:744 _apply_op_helper
        attrs=attr_protos, op_def=op_def)
    /root/.local/lib/python3.6/site-packages/tensorflow/python/framework/func_graph.py:595 _create_op_internal
        compute_device)
    /root/.local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py:3470 _create_op_internal
        op_def=op_def)
    /root/.local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py:1960 __init__
        control_input_ops, op_def)
    /root/.local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py:1800 _create_c_op
        raise ValueError(str(e))

    ValueError: can't split axis of size 85 into pieces of size [2,2,1,20] for '{{node yolo_loss/split}} = SplitV[T=DT_FLOAT, Tlen=DT_INT32, num_split=4](model/layer_207_output_0/layer_206_lambda/Reshape, yolo_loss/Const, yolo_loss/split/split_dim)' with input shapes: [?,?,?,3,85], [4], [] and with computed input tensors: input[1] = <2 2 1 20>, input[2] = <-1>

推荐答案

这是由于没有相同的节点数:在这里85不能被转换或调整大小为2 * 2 * 1 * 20等于80 您可以调整形状或调整大小,仅节点值相等
在您的情况下85不等于2 * 2 * 1 * 20(80)

this is due to not having same no of nodes: Here 85 cannot be convert or resize into 2*2*1*20 which is equal to 80 you can reshape or resize only node value are equal
In you case 85 is not equal to 2*2*1*20(80)

这篇关于ValueError:无法将大小为85的轴拆分为大小为[2,2,1,20]的keras训练的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆