I have a function make_model()
which works fine everywhere and I ran it on my raspberry pi in the morning and it worked fine but now it gets the following error:
Using TensorFlow backend.
2020-07-11 15:15:18.946541: W tensorflow/core/framework/cpu_allocator_impl.cc:81] Allocation of 2097152 exceeds 10% of system memory.
2020-07-11 15:15:18.952599: W tensorflow/core/framework/cpu_allocator_impl.cc:81] Allocation of 2097152 exceeds 10% of system memory.
2020-07-11 15:15:18.955832: W tensorflow/core/framework/cpu_allocator_impl.cc:81] Allocation of 2097152 exceeds 10% of system memory.
2020-07-11 15:15:19.100194: W tensorflow/core/framework/cpu_allocator_impl.cc:81] Allocation of 4194304 exceeds 10% of system memory.
2020-07-11 15:15:19.112173: W tensorflow/core/framework/cpu_allocator_impl.cc:81] Allocation of 4194304 exceeds 10% of system memory.
Train on 184 samples, validate on 46 samples
Epoch 1/32
32/184 [====>.........................] - ETA: 2s - loss: 2.8498 - accuracy: 0. 64/184 [=========>....................] - ETA: 1s - loss: 2.7108 - accuracy: 0. 96/184 [==============>...............] - ETA: 0s - loss: 2.6015 - accuracy: 0.128/184 [===================>..........] - ETA: 0s - loss: 2.4629 - accuracy: 0.160/184 [=========================>....] - ETA: 0s - loss: 2.3413 - accuracy: 0.5813Bus error
This is my code:
class SoftMax():
def __init__(self, input_shape, num_classes):
self.input_shape = input_shape
self.num_classes = num_classes
def build(self):
#create model
model = Sequential()
#add model layers
model.add(Dense(1024, activation='relu', input_shape=self.input_shape))
model.add(Dropout(0.5))
model.add(Dense(1024, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(self.num_classes, activation='softmax'))
# loss and optimizer
optimizer=Adam(learning_rate=0.001, beta_1=0.9, beta_2=0.999, amsgrad=False)
model.compile(loss=categorical_crossentropy,
optimizer=optimizer,
metrics=['accuracy'])
return model
def make_model(args, classifier=SoftMax):
# Load the face embeddings
data = pickle.loads(open(args.embeddings, "rb").read())
num_classes = len(np.unique(data["names"]))
ct = ColumnTransformer([('myٔName', OneHotEncoder(), [0])])
labels = np.array(data["names"]).reshape(-1, 1)
labels = ct.fit_transform(labels)
embeddings = np.array(data["embeddings"])
# Initialize Softmax training model arguments
BATCH_SIZE = 32
EPOCHS = 32
input_shape = embeddings.shape[1]
# Build classifier
init_classifier = classifier(input_shape=(input_shape,), num_classes=num_classes)
model = init_classifier.build()
# Create KFold
cv = KFold(n_splits = 5, random_state = None, shuffle=True)
history = {'acc': [], 'val_acc': [], 'loss': [], 'val_loss': []}
# Train
for train_idx, valid_idx in cv.split(embeddings):
X_train, X_val, y_train, y_val = embeddings[train_idx], embeddings[valid_idx], labels[train_idx], labels[valid_idx]
his = model.fit(X_train, y_train, batch_size=BATCH_SIZE, epochs=EPOCHS, verbose=1, validation_data=(X_val, y_val))
# write the face recognition model to output
model.save(args.mymodel)
f = open(args.le, "wb")
f.write(pickle.dumps(LabelEncoder()))
f.close()
Can someone help me? what's the issue?