VisibleDeprecationWarning:使用非整数而不是整数会在将来导致错误

用户288609:

当运行包含以下功能的python程序时,image[x,y] = 0给出以下错误消息。这是什么意思,以及如何解决?谢谢。

警告

VisibleDeprecationWarning: using a non-integer number instead of an integer   
will result in an error in the future
image[x,y] = 0
Illegal instruction (core dumped)

def create_image_and_label(nx,ny):
  x = np.floor(np.random.rand(1)[0]*nx)
  y = np.floor(np.random.rand(1)[0]*ny)

  image = np.ones((nx,ny))
  label = np.ones((nx,ny))
  image[x,y] = 0
  image_distance = ndimage.morphology.distance_transform_edt(image)

  r = np.random.rand(1)[0]*(r_max-r_min)+r_min
  plateau = np.random.rand(1)[0]*(plateau_max-plateau_min)+plateau_min

  label[image_distance <= r] = 0 
  label[image_distance > r] = 1
  label = (1 - label)

  image_distance[image_distance <= r] = 0 
  image_distance[image_distance > r] = 1
  image_distance = (1 - image_distance)*plateau

  image = image_distance + np.random.randn(nx,ny)/sigma

  return image, label[92:nx-92,92:nx-92]
maxymoo:

警告是说不要使用浮点数来索引数组。np.int代替np.floor

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Python-使用非整数而不是整数

在NASM中使用scanf将非整数输入无符号整数会导致循环问题

使用变量而不是整数时nuXmv语法错误

是什么导致此错误“ struct.error:必需的参数不是整数”?

错误“要求的对齐方式不是整数常量”

是否有与非可读性相关的原因,而不是每次都不专门使用固定宽度的整数?

.loc数据帧导致值错误无法将非限定值(NA或inf)转换为整数

为什么使用无限for循环将无符号整数相加会导致错误的结果?

为什么非整数输入会导致无限循环?

compojure解构使整数...不是整数?

为什么使用整数而不是Long?

只使用整数而不是十进制

TypeError:列表索引必须是整数,而不是使用.format时的str错误

类型错误:使用 MTCNN 时,元组索引必须是整数或切片,而不是 str

使用约束生成随机非整数 Python

整数转换导致截断

取消引用整数指针会导致分段错误

整数到无符号转换将导致VHDL Quartus错误

传递整数数组作为参数导致的C ++错误

字符和整数级联何时会导致段错误?

Fortran 95中的长整数会导致“错误:整数与其种类太大”

在Visual Studio中使用文字整数分配的奇怪行为会导致四个意外的编译器错误

PG :: DatatypeMismatch:错误:AND的参数必须为布尔型,而不是整数

榆树返回整数而不是布尔,编译器错误?

C中带有指针的“错误:数组下标不是整数”

类型错误:列表索引必须是整数,而不是标签 -- python

错误列表索引必须是整数或切片,而不是str

Python 2.7:类型错误:列表索引必须是整数,而不是 str

如果卷不是整数,python 中的语法错误