我在手电筒中有一个代码,必须将其更改为keras,但是当我为以下代码执行此操作时,会产生此错误:
回溯(最近通话最近一次):
文件“”的第3行,在 jpe [channel] = mask
TypeError:“ RefVariable”对象不支持项目分配
我认为此错误是针对分配的,但我不知道该如何解决。火炬的主要代码是:
yuv_keep_weighs=(25,9,9)
requested_shape=(100,100)
jpeg_mask=None
if jpeg_mask is None or requested_shape > jpeg_mask.shape[1:]:
jpeg_mask = torch.empty((3,) + requested_shape)
for channel, weights_to_keep in enumerate(yuv_keep_weighs):
mask = torch.from_numpy(get_jpeg_yuv_filter_mask(requested_shape, 8, weights_to_keep))
jpeg_mask[channel] = mask
我更改了
yuv_keep_weighs=(25,9,9)
requested_shape=(100,100)
jpeg_mask=None
if jpeg_mask is None or requested_shape > jpeg_mask.shape[1:]:
jpeg_mask = K.zeros((3,) + requested_shape)
for channel, weights_to_keep in enumerate(yuv_keep_weighs):
mask = K.variable(get_jpeg_yuv_filter_mask(requested_shape, 8, weights_to_keep))
jpeg_mask[channel] = mask
但是最后一行会产生错误,我不知道如何在tensorflow中进行赋值?请指导我有关这个问题。