PaddlePaddle出现错误op uniform_random does not have kernel for data_type

  • 问题描述:使用Fluid实现机器翻译模型时,报op uniform_random does not have kernel for data_type

  • 报错输出:

Traceback (most recent call last):
  File "train.py", line 173, in 
    train()
  File "train.py", line 103, in train
    exe.run(framework.default_startup_program())
  File "/Users/jizhi/anaconda3/envs/paddle/lib/python3.5/site-packages/paddle/fluid/executor.py", line 470, in run
    self.executor.run(program.desc, scope, 0, True, True)
paddle.fluid.core.EnforceNotMet: op uniform_random does not have kernel for data_type[int64_t]:data_layout[ANY_LAYOUT]:place[CPUPlace]:library_type[PLAIN] at [/Users/paddle/minqiyang/Paddle/paddle/fluid/framework/operator.cc:726]
PaddlePaddle Call Stacks:
0          0x1197e4a68p paddle::platform::EnforceNotMet::EnforceNotMet(std::exception_ptr, char const*, int) + 760
1          0x11a60d558p paddle::framework::OperatorWithKernel::RunImpl(paddle::framework::Scope const&, boost::variant const&) const + 1480
2          0x11a609141p paddle::framework::OperatorBase::Run(paddle::framework::Scope const&, boost::variant const&) + 577
3          0x1198b23a6p paddle::framework::Executor::RunPreparedContext(paddle::framework::ExecutorPrepareContext*, paddle::framework::Scope*, bool, bool, bool) + 390
4          0x1198b1dd3p paddle::framework::Executor::Run(paddle::framework::ProgramDesc const&, paddle::framework::Scope*, int, bool, bool) + 163
5          0x119818837p void pybind11::cpp_function::initialize(paddle::pybind::pybind11_init()::$_64&&, void (*)(paddle::framework::Executor&, paddle::framework::ProgramDesc const&, paddle::framework::Scope*, int, bool, bool), pybind11::name const&, pybind11::is_method const&, pybind11::sibling const&)::'lambda'(pybind11::detail::function_call&)::__invoke(pybind11::detail::function_call&) + 135
6          0x1197ef3aap pybind11::cpp_function::dispatcher(_object*, _object*, _object*) + 5786
7          0x10ca8859fp PyCFunction_Call + 127
8          0x10cb537e7p PyEval_EvalFrameEx + 33207
9          0x10cb49fafp _PyEval_EvalCodeWithName + 335
10         0x10cb502a7p PyEval_EvalFrameEx + 19575
11         0x10cb49fafp _PyEval_EvalCodeWithName + 335
12         0x10cb502a7p PyEval_EvalFrameEx + 19575
13         0x10cb49fafp _PyEval_EvalCodeWithName + 335
14         0x10cb9c758p PyRun_FileExFlags + 248
15         0x10cb9beeep PyRun_SimpleFileExFlags + 382
16         0x10cbc0d86p Py_Main + 3622
17         0x10ca02861p main + 497
18      0x7fff5f4da015p start + 1
19                 0x2p
  • 相关代码:
src_word_idx = fluid.layers.data(
        name='source_sequence', shape=[1], dtype='int64', lod_level=1)
        
src_embedding = fluid.layers.embedding(
input=src_word_idx,
size=[source_dict_dim, embedding_dim],
dtype='int64')
  • 解决方法:
src_word_idx = fluid.layers.data(
        name='source_sequence', shape=[1], dtype='int64', lod_level=1)

src_embedding = fluid.layers.embedding(
    input=src_word_idx,
    size=[source_dict_dim, embedding_dim],
    dtype='float32')

你可能感兴趣的:(PaddlePaddle,问答专区)