Python &引用;“进程停止”;在使用vgg模型计算模型后的预测期间
我目前面临着我的Python &引用;“进程停止”;在使用vgg模型计算模型后的预测期间,python,linux,tensorflow,keras,Python,Linux,Tensorflow,Keras,我目前面临着我的Tensorflow管道的问题。 不知道它是特定于Tensorflow还是Python 在我编译的vgg16模型之后,我试图做一个混淆矩阵。 因此,我使用拟合方法得到的模型对象,并尝试预测相同的特征来计算我的CM 但英文中出现了“Processus arrêté”或process stopped的消息,脚本停止工作 以下是输出: Using TensorFlow backend. Load audio features and labels : 100%
Tensorflow
管道的问题。
不知道它是特定于Tensorflow
还是Python
在我编译的vgg16
模型之后,我试图做一个混淆矩阵。
因此,我使用拟合方法得到的模型对象,并尝试预测相同的特征来计算我的CM
但英文中出现了“Processus arrêté”或process stopped的消息,脚本停止工作
以下是输出:
Using TensorFlow backend.
Load audio features and labels : 100% Time: 0:00:50 528.41 B/s
VGG16 model with last layer changed
Number of label: 17322
Model: "sequential"
我已经找到了为什么会这样
只是因为记忆。我的内存RAM不够大,无法计算我拥有的数据总量我发现了为什么会出现这种情况 只是因为记忆。我的内存RAM不够大,无法计算我拥有的数据总量
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
vgg16 (Functional) (None, 4, 13, 512) 14713536
_________________________________________________________________
flatten (Flatten) (None, 26624) 0
_________________________________________________________________
dense (Dense) (None, 256) 6816000
_________________________________________________________________
dropout (Dropout) (None, 256) 0
_________________________________________________________________
dense_1 (Dense) (None, 1) 257
=================================================================
Total params: 21,529,793
Trainable params: 13,895,681
Non-trainable params: 7,634,112
_________________________________________________________________
2772/2772 [==============================] - 121s 44ms/step - loss: 0.2315 - acc: 0.9407 - val_loss: 0.0829 - val_acc: 0.9948
Processus arrêté
Here is the model :
def launch2(self):
print("VGG16 model with last layer changed")
x = np.array(self.getFeatures())[...,np.newaxis]
print("Number of label: " + str(len(self.getLabels())))
vgg_conv=VGG16(weights=None, include_top=False, input_shape=(128, 431, 1))
#Freeze the layers except the last 4 layers
for layer in vgg_conv.layers[:-4]:
layer.trainable = False
#Create the model
model = tensorflow.keras.Sequential()
#Add the vgg convolutional base model
model.add(vgg_conv)
opt = Adam(lr=1e-4)
model.add(Flatten())
model.add(Dense(256, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(1, activation="sigmoid"))
model.compile(optimizer=opt, loss='binary_crossentropy', metrics=['acc'])
model.summary()
model.fit(x=x,y=self.getLabels(),shuffle=True,batch_size=5,epochs=1, validation_split=0.2, verbose=1)
model.save('vggModelLastLayer.h5')
self.testModel(model,x)
Here is the function which allow me to compute the CM :
def testModel(self, model,x):
print("Informations about model still processing. Last step is long")
y_labels = [int(i) for i in self.getLabels().tolist()]
classes = model.predict_classes(x)
predicted_classes = np.argmax(results, axis=1)
# Call model info (true labels, predited labels)
#self.modelInfo(y_labels, predicted_classes)
from sklearn.metrics import classification_report
from sklearn.metrics import confusion_matrix
cm=confusion_matrix(y_labels,predicted_classes)
target_names=["Bulls","No bulls"]
print(classification_report(y_labels,predicted_classes, target_names=target_names))
print(cm)
How could I fix this ? Is this a memory leak or something ?
Thank you in advance