import osimport numpy as npfrom PIL import Imagefrom pylab import *import matplotlib.pyplot as pltfrom scipy.misc import imresize# read datadata_dir = "F:\\dataSet\\cifar-10-batches-py"testdata_dir="F:\\dataSet\\cifar-10-batches-py\\test_batch"da=np.load(testdata_dir)testdata=da['data']testlabel=np.array(da['labels'])
train=np.empty((50000,3072))label=np.empty((50000,))for i in range(1,2): str='data_batch_'+np.str(i) path1=os.path.join(data_dir,str) data=np.load(path1) train[10000*(i-1):10000*i,:]=data['data'] label[10000*(i-1):10000*i,]=data['labels']
def intlabel(label): for i in range(label.shape[0]): label[i,]=int(float(label[i,])) return label
def intdata(data): n=data.shape[0] for i in range(n): for j in range(3072): data[i,j]=int(float(data[i,j])) return data
label,train=intlabel(label),intdata(train)train,label=np.array(train),np.array(label)
from keras.datasets import cifar10
import cv2(X_train, y_train), (X_test, y_test) = cifar10.load_data()
data_upscaled = np.zeros((50000, 3, 227, 227))
for i, img in enumerate(X_train):
im = img.reshape((1, 2, 0))
large_img = cv2.resize(im, dsize=(227, 227), interpolation=cv2.INTER_CUBIC)
data_upscaled[i] = large_img.reshape((2, 0, 1))cannot reshape array of size 3072 into shape (1,2,0)
import numpy as np
from keras.datasets import cifar10
import cv2
(X_train, y_train), (X_test, y_test) = cifar10.load_data()
data_upscaled = np.zeros(50000, 3, 227, 227)
for i, img in enumerate(X_train):
im = np.transpose(img, (1, 2, 0))
large_img = cv2.resize(im, dsize=(227, 227), interpolation=cv2.INTER_CUBIC)
data_upscaled[i] = np.transpose(large_img, (2, 0, 1))
--
You received this message because you are subscribed to the Google Groups "Keras-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to keras-users...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/keras-users/7c3672bf-b7b7-49a1-9f41-c631da8b0171n%40googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/keras-users/CAP0ykh8nN2C8XVO59GidR8n%3DRiSu8AHGbmY4ao1tSosiBqGRWA%40mail.gmail.com.