Paddle Accuracy接口pred, label只支持二维吗?

pgx2nnw8  于 2021-12-07  发布在  Java
关注(0)|答案(3)|浏览(422)

Paddle2.0rc中的paddle.metric.Accuracy,pred,label只能用二维吗?高级接口也没有说明文档的用法,不太会使用,总是报错

Epoch 1/200

---------------------------------------------------------------------------EnforceNotMet Traceback (most recent call last) in
21 epochs = args["epochs"],
22 batch_size=args["batch_size"],
---> 23 verbose=1)
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/hapi/model.py in fit(self, train_data, eval_data, batch_size, epochs, eval_freq, log_freq, save_dir, save_freq, verbose, drop_last, shuffle, num_workers, callbacks)
1467
1468 cbks.on_epoch_begin(epoch)
-> 1469 logs = self._run_one_epoch(train_loader, cbks, 'train')
1470 cbks.on_epoch_end(epoch, logs)
1471
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/hapi/model.py in _run_one_epoch(self, data_loader, callbacks, mode, logs)
1837 if mode != 'test':
1838 outs = getattr(self, mode + '_batch')(data[:len(self._inputs)],
-> 1839 data[len(self._inputs):])
1840 if self._metrics and self._loss:
1841 metrics = l[0] for l in outs[0]
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/hapi/model.py in train_batch(self, inputs, labels)
935 print(loss)
936 """
--> 937 loss = self._adapter.train_batch(inputs, labels)
938 if fluid.in_dygraph_mode() and self._input_shapes is None:
939 self._update_inputs()
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/hapi/model.py in train_batch(self, inputs, labels)
668 metrics = []
669 for metric in self.model._metrics:
--> 670 metric_outs = metric.compute((to_list(outputs) + labels))
671 m = metric.update(
[to_numpy(m) for m in to_list(metric_outs)])
672 metrics.append(m)
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/metric/metrics.py in compute(self, pred, label, *args)
245 """
246 pred = paddle.argsort(pred, descending=True)[:, :self.maxk]
--> 247 correct = pred == label
248 return paddle.cast(correct, dtype='float32')
249
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/dygraph/math_op_patch.py inimpl(self, other_var)
183 axis = -1
184 math_op = getattr(core.ops, op_type)
--> 185 return math_op(self, other_var, 'axis', axis)
186
187 comment = OpProtoHolder.instance().get_op_proto(op_type).comment
EnforceNotMet:

Error Message Summary:

InvalidArgumentError: Broadcast dimension mismatch. Operands could not be broadcast together with the shape of X = [32, 1] and the shape of Y = [32, 160, 160]. Received [32] in X is not equal to [160] in Y at i:1.
[Hint: Expected x_dims_array[i] == y_dims_array[i] || x_dims_array[i] <= 1 || y_dims_array[i] <= 1 == true, but received x_dims_array[i] == y_dims_array[i] || x_dims_array[i] <= 1 || y_dims_array[i] <= 1:0 != true:1.] (at /paddle/paddle/fluid/operators/elementwise/elementwise_op_function.h:160)
[operator < equal > error]

rjee0c15

rjee0c151#

您好,我们已经收到了您的问题,会安排技术人员尽快解答您的问题,请耐心等待。请您再次检查是否提供了清晰的问题描述、复现代码、环境&版本、报错信息等。同时,您也可以通过查看官网API文档常见问题历史IssueAI社区来寻求解答。祝您生活愉快~

Hi! We've received your issue and please be patient to get responded. We will arrange technicians to answer your questions as soon as possible. Please make sure that you have posted enough message to demo your request. You may also check out the APIFAQGithub Issue and AI community to get the answer.Have a nice day!

ia2d9nvy

ia2d9nvy2#

@Darki-luo 2.0rc确实仅仅支持维度。新发布的2.0rc1支持高纬度,label支持了rank为1的、多维、one-hot的。

pb3skfrl

pb3skfrl3#

rc1有pip包吗,或者什么时候会发布?

相关问题