TypeError: only integer scalar arrays can be converted to a scalar index一例
问题重现:
# -*- coding: utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
# @Author: appleyuchi
# @Date: 2018-12-31 16:11:34
# @Last Modified by: appleyuchi
# @Last Modified time: 2018-12-31 16:54:56import numpy as np
from hmmlearn import hmmstates = ["box 1", "box 2", "box3"]
n_states = len(states)observations = ["red", "white"]
n_observations = len(observations)start_probability = np.array([0.2, 0.4, 0.4])transition_probability = np.array([[0.5, 0.2, 0.3],[0.3, 0.5, 0.2],[0.2, 0.3, 0.5]
])emission_probability = np.array([[0.5, 0.5],[0.4, 0.6],[0.7, 0.3]
])model = hmm.MultinomialHMM(n_components=n_states)
model.startprob_=start_probability
model.transmat_=transition_probability
model.emissionprob_=emission_probabilityseen = np.array([[0,1,0]]).Tlogprob, box = model.decode(seen, algorithm="viterbi")
# print "observations=",observations
print "seen=",seen# TypeError: only integer scalar arrays can be converted to a scalar indexprint("The ball picked:", ", ".join(map(lambda x: observations[x], seen)))
print("The hidden box", ", ".join(map(lambda x: states[x], box)))
解决方案:
print("The ball picked:", ", ".join(map(lambda x: observations[x], seen)))
改为:
print("The ball picked:", ", ".join(map(lambda x: observations[x], seen[0])))
TypeError: only integer scalar arrays can be converted to a scalar index一例相关推荐
- 成功解决TypeError: only integer scalar arrays can be converted to a scalar index
成功解决TypeError: only integer scalar arrays can be converted to a scalar index 目录 解决问题 解决思路 解决方法 解决问题 ...
- TypeError: only integer scalar arrays can be converted to a scalar index
在取某些索引下的值时,报错TypeError: only integer scalar arrays can be converted to a scalar index data = data[in ...
- moviepy音视频剪辑:AudioClip帧处理时报TypeError: only size-1 arrays can be converted to Python scalar错
☞ ░ 前往老猿Python博文目录 ░ 一.环境 操作系统:win7 64位 moviepy:1.0.3 numpy:1.19.0 Python:3.7.2 二.应用代码及报错信息 程序代码 if ...
- 使用math.sin时报错only size-1 arrays can be converted to Python scalar
代码: import numpy as np x = np.linspace(0,1,6) def f(x):return math.sin(x) y = f(x) 报错: only size-1 a ...
- TypeError: only integer tensors of a single element can be converted to an indexValueError: only one
1.ValueError: only one element tensors can be converted to Python scalars 2.TypeError: only integer ...
- TypeError: only integer tensors of a single element can be converted to an index
在调整loss计算的时候遇到了TypeError: only integer tensors of a single element can be converted to an index这个问题, ...
- TypeError: only size-1 arrays can be converted to Python scalars
正在愉快写代码的我 ??????????? 源代码也很简单 之后可以解决,比如 再比如: 但是那样究竟为什么不对呢? plt.bar(x = x,height=data,width=0.8,align ...
- pyinstaller打包任何py文件TypeError: an integer is required (got type bytes)
pyinstaller打包任何py文件TypeError: an integer is required (got type bytes) 目录 pyinstaller打包任何py文件TypeErro ...
- 读取文件:TypeError: an integer is required (got type str)
读取文件的时候报错: Traceback (most recent call last): File "D:\Python35\test\csdn.py", line 46, in ...
最新文章
- U3D游戏运行时资源是如何从AB中加载出来的
- 最全三大框架整合(使用映射)——数据库资源文件jdbc.properties
- Code Sinppet
- 你(也)是吴恩达的学生么?
- matlab2c使用c++实现matlab函数系列教程-cumsum函数
- 理光打印机如何设置邮件服务器,技术员帮您win10系统网络共享理光打印机的设置方法的操作办法...
- 唐僧给李世民的取经汇报
- 按钮按一下画个直线_直线导轨数控车床概念和作用
- G729调用方法及使用wavlib播放出现颤音的解决方法
- C# 嵌入式数据库LiteDB
- oracle查看锁表语句、解锁方法
- 关于人工智能研究思路的一点设想
- 如何修改网卡的MAC地址?
- input发送a.jax_Java EE 7和JAX-RS 2.0
- 微信公众平台开发(121) 微信二维码海报
- pandas案例之消费金额和消费之间的关联与性别和吸烟与否的关系
- TCP time_wait 的存在意义
- 国内“孩子青春期”图书中的iPhone:正写书的程序员爸爸点评《拆解青春期女孩的小心事》
- 【Qt象棋游戏】07_人机博弈算法开端
- el-select 在iOS手机上,无法唤起软键盘以及二次点击问题
热门文章
- 201509280825_《css3——media query整理2》
- 关于MSSQL数据存储的问题
- phpstudy+dvwa搭建
- apue对java_[apue] 一个快速确定新系统上各类限制值的工具
- vue中动态设置style样式和使用filters过滤器设置样式
- .attr()与.removeAttr()
- java kaptcha_java相关:kaptcha验证码使用方法详解
- Echarts API说明文档
- 微信小程序setTimeout自动跳转页面
- ES6公用跑马灯抽奖组件的封装及使用