在使用 mindspore 训练的神经网络中包含 mindquantum 的量子神经网络时候, 如果量子神经网络输出维度较大的时候运行效率大幅度降低
收藏回复举报
在使用 mindspore 训练的神经网络中包含 mindquantum 的量子神经网络时候, 如果量子神经网络输出维度较大的时候运行效率大幅度降低
t('forum.solved') 已解决
发表于2024-02-12 10:36:05
0 查看
我在用 mindspore 训练一个生成式模型用于生成手写识别图像,其中训练集使用的是 mnist 训练集. 生成式模型是一个量子神经网络, 因为需要生成的图片维度是 28*28 的, 所以量子神经网络中量子电路需要计算 28*28 个哈密顿量的期望的梯度, 也就是在调用函数 sim.get_expectation_with_grad 的时候, 输入的 hams 是一个长度为 28*28 的list, 但是这样一来导致运行效率非常差, 即使我 grad_ops2 = sim.get_expectation_with_grad(hams, 

                                         encoder, 

                                         parallel_worker=batch_size) 当中将 parallel_worker 调整的很高, 但是 CPU 占用率还是非常低. 我在用量子神经网络做二分类问题的时候如果调高 parallel_worker 那么 CPU 的占用可以接近百分之百, 但是在我训练生成式模型的时候占用了只用百分之十左右,同时训练过程中有如下警告: 请问我应该如何调整使得程序可以并行计算多个 hams 的观测值和梯度或者是否需要其它的调整,麻烦了!

[WARNING] MD(280,7fb0c213f700,python):2024-02-12-00:15:45.858.985 [mindspore/ccsrc/minddata/dataset/engine/datasetops/source/generator_op.cc:231] operator()] Bad performance attention, it takes more than 25 seconds to generator.__next__ new row, which might cause `GetNext` timeout problem when sink_mode=True. You can increase the parameter num_parallel_workers in GeneratorDataset / optimize the efficiency of obtaining samples in the user-defined generator function.
[WARNING] MD(280,7fb0c213f700,python):2024-02-12-00:36:14.349.731 [mindspore/ccsrc/minddata/dataset/engine/datasetops/source/generator_op.cc:231] operator()] Bad performance attention, it takes more than 25 seconds to generator.__next__ new row, which might cause `GetNext` timeout problem when sink_mode=True. You can increase the parameter num_parallel_workers in GeneratorDataset / optimize the efficiency of obtaining samples in the user-defined generator function.
[WARNING] MD(280,7fb0c213f700,python):2024-02-12-00:46:24.020.715 [mindspore/ccsrc/minddata/dataset/engine/datasetops/source/generator_op.cc:231] operator()] Bad performance attention, it takes more than 25 seconds to generator.__next__ new row, which might cause `GetNext` timeout problem when sink_mode=True. You can increase the parameter num_parallel_workers in GeneratorDataset / optimize the efficiency of obtaining samples in the user-defined generator function.

我要发帖子