我正在阅读 jpg 图像,然后将它们重塑为张量。我将图像投射为 float32:
def load(folder,table):
X=[]
train = pd.read_csv(table)
for i,img_id in enumerate(train['Image']):
img = io.imread(folder+img_id[2:])
X.append(img)
X = np.array(X)/255.
X = X.astype(np.float32)
X = X.reshape(-1, 1, 225, 225)
return X
但是,我收到此错误
TypeError: ('Bad input argument to theano function with name "/Users/mas/PycharmProjects/Whale/nolearn_convnet/Zahraa5/lib/python2.7/site-packages/nolearn/lasagne/base.py:435" at index 1(0-based)', 'TensorType(int32, vector) cannot store a value of dtype float32 without risking loss of precision. If you do not mind this loss, you can: 1) explicitly cast your data to int32, or 2) set "allow_input_downcast=True" when calling "function".', array([[ 0., 0., 0., ..., 0., 0., 0.],
[ 0., 0., 0., ..., 0., 0., 0.],
[ 0., 0., 0., ..., 0., 0., 0.],
...,
[ 0., 0., 0., ..., 0., 0., 0.],
[ 0., 0., 0., ..., 0., 0., 0.],
[ 0., 0., 0., ..., 0., 0., 0.]], dtype=float32))