python - CNTK Python - one_hot 编码无原型(prototype)

标签 python cntk

我正在尝试使用 cntk.utils.one_hot 如下:

# actions is numpy array of shape (32, 1) and _output_shape is 6
actions = one_hot(actions, self._output_shape)

但它提示不支持类 numpy.float32

我尝试转换为 Python 列表:

actions = one_hot(list(actions), self._output_shape)

我收到以下错误:

  File "/home/malmo_user/Workspace/malmo-collab/msrc-rl/model/backend/cntk.py", line 213, in train
    actions = one_hot(list(actions), self._output_shape)
  File "/home/malmo_user/anaconda3/envs/cntk-py34/lib/python3.4/site-packages/cntk/utils/swig_helper.py", line 58, in wrapper
    result = f(*args, **kwds)
  File "/home/malmo_user/anaconda3/envs/cntk-py34/lib/python3.4/site-packages/cntk/utils/__init__.py", line 76, in one_hot
    value = cntk_py.Value.create_one_hot_float(num_classes, batch, device, False)
NotImplementedError: Wrong number or type of arguments for overloaded function 'Value_create_one_hot_float'.
  Possible C/C++ prototypes are:
    CNTK::Value::CreateOneHotFloat(size_t,std::vector< std::vector< size_t,std::allocator< size_t > >,std::allocator< std::vector< size_t,std::allocator< size_t > > > > const &,CNTK::DeviceDescriptor const &,bool)
    CNTK::Value::CNTK_Value_CreateOneHotFloat__SWIG_0(size_t,std::vector< std::vector< size_t,std::allocator< size_t > >,std::allocator< std::vector< size_t,std::allocator< size_t > > > > const &,CNTK::DeviceDescriptor const &)

最佳答案

one_hot 的输入是索引。它们必须是整数。尝试

actions.astype(int).tolist()

关于python - CNTK Python - one_hot 编码无原型(prototype),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41677508/

相关文章:

python - 类型错误 : 'instancemethod' object is not iterable (Content Spinner)

c++ - 如何从 CNTK 导入 tensorflow 模型?

python - 使用 CNTK 通过在每个生成步骤进行采样来生成序列

CNTK 迁移学习与 LSTM : appending pretrained network to another network

python - 极其基础的神经网络不学习

python - 您如何在 Geraldo Reports 中生成/创建表格?

python - 将 anaconda SDK 添加到 Intellij 项目

python - 在 pandas 索引对象上运行内置方法时出现奇怪的错误

python - 为排名模型创建 Catboost 池时出错

machine-learning - 在深度学习方法中结合临床和图像数据的最佳方法是什么?