There is
train variable of list type, which conatains two elements - array of img type variables and the array of labels. I need to write the first array(of imgs) to
X and then process it with reshape. I used NumPy library.
The code below is for understanding what
train variable is.
training_data.append([np.array(img), np.array(label)])
...
train = train_data[:-500]
I have tried to do it two ways.
First i have had the error:
TypeError: 'int'object is not subscriptable
For the second way i have had the error:
ValueError: setting an array element as a sequence
Update: the code, where training data list was create. The
train is the slice of training_data
def create_train_data():
training_data = [1100]
for img in tqdm(os.listdir(TRAIN_DIR)):
label = label_img(img)
path = os.path.join(TRAIN_DIR, img)
training_data.append([np.array(img), np.array(label)])
shuffle(training_data)
np.save('train_data.npy', training_data)
return training_data
train_data = create_train_data()
train = train_data[:-500]
There is what print(train) gives
https://ibb.co/RQ0H89r
What I have tried:
First way:
X = np.array([i[0] for i in train]).reshape(-1, IMG_SIZE, IMG_SIZE, 1)
Second way:
MyX=np.asarray( train[0])
X = MyX.reshape(-1, IMG_SIZE, IMG_SIZE, 1)