我通过Beta类中的_sample()函数采样一个样本,并用_log_prob()函数求其对数概率,但程序报错显示gamma算子不支持在CPU使用
源代码如下
报错显示如下
Traceback (most recent call last):
File "E:\test\pythonProject2\train\sim_train.py", line 18, in <module>
main(args)
File "E:\test\pythonProject2\train\sim_train.py", line 10, in main
runner.run(60 * 10) # 10min
File "E:\test\pythonProject2\runner\shared\sim_runner.py", line 111, in run
a, a_logprob = agent.choose_action(s) # Action and the corresponding log probability
File "E:\test\pythonProject2\algorithms_ms\algorithm_ms\actor_critic_ms.py", line 173, in choose_action
a_logprob = dist._log_prob(a) # The log probability density of the action
File "E:\test\pythonProject2\.venv\lib\site-packages\mindspore\nn\probability\distribution\beta.py", line 323, in _log_prob
return log_unnormalized_prob - self.lbeta(concentration1, concentration0)
File "E:\test\pythonProject2\.venv\lib\site-packages\mindspore\nn\cell.py", line 705, in __call__
raise err
File "E:\test\pythonProject2\.venv\lib\site-packages\mindspore\nn\cell.py", line 701, in __call__
output = self._run_construct(args, kwargs)
File "E:\test\pythonProject2\.venv\lib\site-packages\mindspore\nn\cell.py", line 482, in _run_construct
output = self.construct(*cast_inputs, **kwargs)
File "E:\test\pythonProject2\.venv\lib\site-packages\mindspore\nn\layer\math.py", line 735, in construct
log_beta_one_large = self.lgamma(x_min) + log_gamma_difference_big_y
File "E:\test\pythonProject2\.venv\lib\site-packages\mindspore\nn\cell.py", line 705, in __call__
raise err
File "E:\test\pythonProject2\.venv\lib\site-packages\mindspore\nn\cell.py", line 701, in __call__
output = self._run_construct(args, kwargs)
File "E:\test\pythonProject2\.venv\lib\site-packages\mindspore\nn\cell.py", line 482, in _run_construct
output = self.construct(*cast_inputs, **kwargs)
File "E:\test\pythonProject2\.venv\lib\site-packages\mindspore\nn\layer\math.py", line 237, in construct
input_dtype = self.dtype(x)
File "E:\test\pythonProject2\.venv\lib\site-packages\mindspore\ops\operations\array_ops.py", line 268, in __call__
return x.dtype
File "E:\test\pythonProject2\.venv\lib\site-packages\mindspore\common\_stub_tensor.py", line 94, in dtype
self.stub_dtype = self.stub.get_dtype()
RuntimeError:
----------------------------------------------------
- Kernel select failed:
----------------------------------------------------
Unsupported op [Gamma] on CPU, Please confirm whether the device target setting is correct, or refer to 'mindspore.ops' at https://www.mindspore.cn to query the operator support list.
node: @kernel_graph_14:CNode_4{[0]: ValueNode<Primitive> Gamma, [1]: ValueNode<Tensor> Tensor(shape=[2], dtype=Int64, value=[1 1]), [2]: @kernel_graph_14:param_Parameter_5, [3]: @kernel_graph_14:param_Parameter_6}
----------------------------------------------------
- C++ Call Stack: (For framework developers)
----------------------------------------------------
mindspore\ccsrc\plugin\device\cpu\hal\hardware\cpu_device_context.cc:386 mindspore::device::cpu::CPUKernelExecutor::SetOperatorInfo
我通过Beta类中的_sample()函数采样一个样本,并用_log_prob()函数求其对数概率,但程序报错显示gamma算子不支持在CPU使用
源代码如下
def get_dist(self, s): alpha, beta = self.forward(s) dist = nn.probability.distribution.Beta(alpha, beta) return dist报错显示如下
Traceback (most recent call last):
File "E:\test\pythonProject2\train\sim_train.py", line 18, in <module>
main(args)
File "E:\test\pythonProject2\train\sim_train.py", line 10, in main
runner.run(60 * 10) # 10min
File "E:\test\pythonProject2\runner\shared\sim_runner.py", line 111, in run
a, a_logprob = agent.choose_action(s) # Action and the corresponding log probability
File "E:\test\pythonProject2\algorithms_ms\algorithm_ms\actor_critic_ms.py", line 173, in choose_action
a_logprob = dist._log_prob(a) # The log probability density of the action
File "E:\test\pythonProject2\.venv\lib\site-packages\mindspore\nn\probability\distribution\beta.py", line 323, in _log_prob
return log_unnormalized_prob - self.lbeta(concentration1, concentration0)
File "E:\test\pythonProject2\.venv\lib\site-packages\mindspore\nn\cell.py", line 705, in __call__
raise err
File "E:\test\pythonProject2\.venv\lib\site-packages\mindspore\nn\cell.py", line 701, in __call__
output = self._run_construct(args, kwargs)
File "E:\test\pythonProject2\.venv\lib\site-packages\mindspore\nn\cell.py", line 482, in _run_construct
output = self.construct(*cast_inputs, **kwargs)
File "E:\test\pythonProject2\.venv\lib\site-packages\mindspore\nn\layer\math.py", line 735, in construct
log_beta_one_large = self.lgamma(x_min) + log_gamma_difference_big_y
File "E:\test\pythonProject2\.venv\lib\site-packages\mindspore\nn\cell.py", line 705, in __call__
raise err
File "E:\test\pythonProject2\.venv\lib\site-packages\mindspore\nn\cell.py", line 701, in __call__
output = self._run_construct(args, kwargs)
File "E:\test\pythonProject2\.venv\lib\site-packages\mindspore\nn\cell.py", line 482, in _run_construct
output = self.construct(*cast_inputs, **kwargs)
File "E:\test\pythonProject2\.venv\lib\site-packages\mindspore\nn\layer\math.py", line 237, in construct
input_dtype = self.dtype(x)
File "E:\test\pythonProject2\.venv\lib\site-packages\mindspore\ops\operations\array_ops.py", line 268, in __call__
return x.dtype
File "E:\test\pythonProject2\.venv\lib\site-packages\mindspore\common\_stub_tensor.py", line 94, in dtype
self.stub_dtype = self.stub.get_dtype()
RuntimeError:
----------------------------------------------------
- Kernel select failed:
----------------------------------------------------
Unsupported op [Gamma] on CPU, Please confirm whether the device target setting is correct, or refer to 'mindspore.ops' at https://www.mindspore.cn to query the operator support list.
node: @kernel_graph_14:CNode_4{[0]: ValueNode<Primitive> Gamma, [1]: ValueNode<Tensor> Tensor(shape=[2], dtype=Int64, value=[1 1]), [2]: @kernel_graph_14:param_Parameter_5, [3]: @kernel_graph_14:param_Parameter_6}
----------------------------------------------------
- C++ Call Stack: (For framework developers)
----------------------------------------------------
mindspore\ccsrc\plugin\device\cpu\hal\hardware\cpu_device_context.cc:386 mindspore::device::cpu::CPUKernelExecutor::SetOperatorInfo