【问题标题】:Expected an Integer期望一个整数
【发布时间】:2019-08-20 06:35:49
【问题描述】:

我在代码的最后一行出现错误。说“期望一个整数”。 实际上这段代码取自 VGGNET。我正在使用 Python 3.6.9。

import theano.tensor as T
batch,in_channels,H,W = T.shape(x)
self.VGGout_resize = 16
xt = x[:,::-1,:,:]
xt = T.set_subtensor(xt[:,0,:,:], xt[:,0,:,:] - 103.939)
xt = T.set_subtensor(xt[:,1,:,:], xt[:,1,:,:] - 116.779)
xt = T.set_subtensor(xt[:,2,:,:], xt[:,2,:,:] - 123.68)
xt = xt[:,:,0:self.VGGout_resize* 
(H/self.VGGout_resize),0:self.VGGout_resize*(W/self.VGGout_resize) ]

"Error Results Image 1" "Error Results Image 2"

【问题讨论】:

  • 请发布带有完整回溯的完整错误消息。

标签: python image-processing theano video-tracking


【解决方案1】:

这可能是因为您正在切片并且(H/self.VGGout_resize)(W/self.VGGout_resize) 的输出可能是非整数。试试这个:

self.VGGout_resize = 16
xt = x[:,::-1,:,:]
xt = T.set_subtensor(xt[:,0,:,:], xt[:,0,:,:] - 103.939)
xt = T.set_subtensor(xt[:,1,:,:], xt[:,1,:,:] - 116.779)
xt = T.set_subtensor(xt[:,2,:,:], xt[:,2,:,:] - 123.68)
xt = xt[:,:,0:self.VGGout_resize*int(H/self.VGGout_resize),0:self.VGGout_resize*int(W/self.VGGout_resize)]

【讨论】:

  • TypeError: int() argument must be a string, a bytes-like object or a number, not 'TensorVariable' 我在进行类型转换时遇到此错误
  • 你的 H 和 W 是什么?你能告诉我声明它们的代码吗?
  • batch,in_channels,H,W = T.shape(x)
猜你喜欢
  • 2020-02-15
  • 1970-01-01
  • 1970-01-01
  • 2021-11-11
  • 2021-03-18
  • 2018-10-18
  • 2017-12-31
  • 2020-09-25
  • 1970-01-01
相关资源
最近更新 更多