gpt4 book ai didi

python - 期望一个整数

转载 作者:太空宇宙 更新时间:2023-11-03 20:29:57 24 4
gpt4 key购买 nike

我在代码的最后一行遇到错误。说“需要一个整数”。实际上这段代码取自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"

最佳答案

这可能是因为您正在切片,并且 (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)]

关于python - 期望一个整数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57567891/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com