我正在尝试将Keras模型转换为PyTorch。现在,它涉及来自keras的keras。当我在pytorch中使用torch.nn.UpsamplingNearest2d时,由于UpSampling2D在keras中的默认值是nearest,因此得到了不同的不一致结果。PyTorch Behaviour
In [
因此,我希望将32x512转换为128x128,保持其一致性4,32x128部件堆叠如下:
如何在PyTorch模型中做这样的事情?下面是我基于所做的尝试x = torch.arange(32*512*3*2).reshape(2, 3, 32, 512)print(f" xx {len(x)} {iii.shape for iii in x }")
x =
然后,我想将该文件夹的图像转换为一个形状数组(图像数量,32,32,3),我目前正在对它们进行整形,并使用keras.preprocessing.image.dataGenerator,然后使用.flow_from_directory当我尝试这样做时,它会抛出一个错误,即它无法将形状的输入数组(8,32,32,3)广播到数组大小(8)。为什么它要重塑阵列。抱歉,我对这一切很陌生。这是我的密码。import tensorflow as tf
from keras.preprocessing.image import img_