运行tensorflow程序,出现ImportError: cannot import name '_validate_lengths’错误的解决办法

如下图:

原因

问题原因:这是skimage版本的问题。找不到_validate_lengths函数,在arraypad.py文件中确实找不到对应的函数,所以找到以前配置过的环境中对应的文件,拷贝这个缺失的函数。

解决办法

搜索这个文件arraypad.py 这个文件。

在最后面添加以下代码,保存退出,问题解决。


def _normalize_shape(ndarray, shape, cast_to_int=True):"""Private function which does some checks and normalizes the possiblymuch simpler representations of ‘pad_width‘, ‘stat_length‘,‘constant_values‘, ‘end_values‘.Parameters----------narray : ndarrayInput ndarrayshape : {sequence, array_like, float, int}, optionalThe width of padding (pad_width), the number of elements on theedge of the narray used for statistics (stat_length), the constantvalue(s) to use when filling padded regions (constant_values), or theendpoint target(s) for linear ramps (end_values).((before_1, after_1), ... (before_N, after_N)) unique number ofelements for each axis where `N` is rank of `narray`.((before, after),) yields same before and after constants for eachaxis.(constant,) or val is a shortcut for before = after = constant forall axes.cast_to_int : bool, optionalControls if values in ``shape`` will be rounded and cast to intbefore being returned.Returns-------normalized_shape : tuple of tuplesval                               => ((val, val), (val, val), ...)[[val1, val2], [val3, val4], ...] => ((val1, val2), (val3, val4), ...)((val1, val2), (val3, val4), ...) => no change[[val1, val2], ]                  => ((val1, val2), (val1, val2), ...)((val1, val2), )                  => ((val1, val2), (val1, val2), ...)[[val ,     ], ]                  => ((val, val), (val, val), ...)((val ,     ), )                  => ((val, val), (val, val), ...)"""ndims = ndarray.ndim# Shortcut shape=Noneif shape is None:return ((None, None), ) * ndims# Convert any input `info` to a NumPy arrayshape_arr = np.asarray(shape)try:shape_arr = np.broadcast_to(shape_arr, (ndims, 2))except ValueError:fmt = "Unable to create correctly shaped tuple from %s"raise ValueError(fmt % (shape,))# Cast if necessaryif cast_to_int is True:shape_arr = np.round(shape_arr).astype(int)# Convert list of lists to tuple of tuplesreturn tuple(tuple(axis) for axis in shape_arr.tolist())def _validate_lengths(narray, number_elements):"""Private function which does some checks and reformats pad_width andstat_length using _normalize_shape.Parameters----------narray : ndarrayInput ndarraynumber_elements : {sequence, int}, optionalThe width of padding (pad_width) or the number of elements on the edgeof the narray used for statistics (stat_length).((before_1, after_1), ... (before_N, after_N)) unique number ofelements for each axis.((before, after),) yields same before and after constants for eachaxis.(constant,) or int is a shortcut for before = after = constant for allaxes.Returns-------_validate_lengths : tuple of tuplesint                               => ((int, int), (int, int), ...)[[int1, int2], [int3, int4], ...] => ((int1, int2), (int3, int4), ...)((int1, int2), (int3, int4), ...) => no change[[int1, int2], ]                  => ((int1, int2), (int1, int2), ...)((int1, int2), )                  => ((int1, int2), (int1, int2), ...)[[int ,     ], ]                  => ((int, int), (int, int), ...)((int ,     ), )                  => ((int, int), (int, int), ...)"""normshp = _normalize_shape(narray, number_elements)for i in normshp:chk = [1 if x is None else x for x in i]chk = [1 if x >= 0 else -1 for x in chk]if (chk[0] < 0) or (chk[1] < 0):fmt = "%s cannot contain negative values."raise ValueError(fmt % (number_elements,))return normshp

参考:
https://www.cnblogs.com/lixiansheng/p/10293323.html

运行tensorflow程序,出现ImportError: cannot import name '_validate_lengths'错误的解决办法相关推荐

  1. android studio运行的时候出现Unable to obtain debug bridge错误的解决办法

    先贴上我百度的: 首先利用win+R,输入cmd,并且输入命令好来到:cd D:\Android\sdk\platform-tools\(这个是我的adb.exe目录,你的可以自行搜索) 然后输入:a ...

  2. linux 错误处理命令,Linux运行脚本命令提示No such file or directory错误的解决办法

    如果在windows中写好python脚本测试正常,但是上传到linux以脚本方式运行命令时提示No such file or directory错误,那么一般是文件格式是dos格式的缘故,改成uni ...

  3. ImportError: cannot import name 'Graph' from 'pyecharts' 解决办法

    最近 pyecharts 包的结构进行了调整,Graph 模块已经不在根目录导致 ImportError,引入语句改成如下即可: from pyecharts.charts.basic_charts. ...

  4. 含有多个java程序的文件夹导入MyEclipes 出现错误的解决办法

    只要在每个 .java(点java)文件中写上包名即可. eg: container BasicContainer.java 只需在程序第一行写上  package container:即可 More ...

  5. 解决“ImportError: cannot import name ‘_validate_lengths‘”问题

    问题描述 在运行程序的时候报错: Traceback (most recent call last):File "demo_heat_map.py", line 2, in < ...

  6. Win7 IIS7.5运行ASP时出现500错误的解决办法

    http 500内部服务器错误说明IIS服务器无法解析ASP代码,下面为大家介绍下Win7 IIS7.5运行ASP时出现500错误的解决办法 http 500内部服务器错误说明IIS服务器无法解析AS ...

  7. 运行java提示找不到符号_运行java代码时出现找不到符号错误怎么解决

    运行java代码时出现找不到符号错误怎么解决 发布时间:2020-06-23 11:37:00 来源:亿速云 阅读:113 作者:Leah 运行java代码时出现找不到符号错误怎么解决?针对这个问题, ...

  8. VS2019运行OpenGL时出现的常见错误及解决办法

    OpenGL程序在低版本的VS中运行成功,但在VS2019中运行却出现各种错误,以下是常见错误的解决办法.(文章结尾有库的链接哟~) 问题一:无法打开文件"glaux.lib" 解 ...

  9. 【Vivado那些事儿】Vivado中运行时出现visual c++运行错误的解决办法

    Vivado中运行时出现visual c++运行错误的解决办法 Win10系统中运行Vivado一直好好的,某一天突然出现visual c++运行错误,如下图所示: 修复也没什么作用,卸载重装是同样的 ...

最新文章

  1. Pytorch的优化器推荐
  2. 帝国cms商城微信小程序之后台sku多规格的开发说明
  3. CSP认证201604-4 游戏[C++题解]:bfs、拆点、迷宫问题加强版、三维数组
  4. 触屏网站如何实现返回并刷新
  5. 浏览器记住密码的自动填充Input问题完美解决方案
  6. cpp怎么转成html,如何编辑HTML(标签),通过CppWebBrowser
  7. 资源 | 我拿到了斯坦福、UCL、CMU、NYU的offer,关于博士申请你需要知道的一切...
  8. leetcode笔记:Validate Binary Search Tree
  9. java heapdump 分析工具_Heapdump分析软件
  10. VAST2.0视频广告投放解决方案改变视频网站未来技术格局
  11. matlab命令行窗口显示长度设置_MATLAB的命令窗口、图形窗口
  12. python输入直角三角形_如何用python做出直角三角形和其形成的锥形
  13. 小雨伞java下载安装教程_TinyUmbrella小雨伞怎么用_TinyUmbrella小雨伞下载及使用教程 - 软件教程 - 格子啦...
  14. 电脑服务器能插无线网卡吗,windows的server版本2016,2019等添加开启无线网卡
  15. Linux下编写C语言
  16. 【springboot】sse接口
  17. 解决 “8080“ 端口号被占用问题!
  18. 模糊PID算法及其MATLAB仿真(1)
  19. Premiere背后的视频剪辑原理
  20. 「JavaSE」-面向对象

热门文章

  1. Linux 下 Shell 命令 IFS 分隔符 -- 应用场景 解决办法
  2. 网络摄像头RTSP拉流协议网页无插件视频直播平台EasyNVR为什么无法获取通道接口数据?
  3. 《区块链技术驱动金融》读书笔记
  4. 信息安全产品体系的介绍
  5. gitlab self-hosted server
  6. win10禁用全角,教你恢复win10系统屏蔽全角/半角快捷键的办法
  7. GD32F303固件库开发(7)----printf打印配置
  8. 为什么计算机屏幕出现黄色,电脑为什么会出现显示器屏幕发黄
  9. 网络分层(7层)以及每层的设备和协议
  10. 26、使用友善NanoPi NEO和外设硬件实现语音唤醒功能、目标检测功能、语音播报功能