This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import _pickle as cPickle | |
| cPickle.dump(train_imgids, open('filename', 'wb')) | |
| data = cPickle.load(open('filename','rb')).tolist() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import zipfile | |
| directory_to_extract_to = '/content/data' | |
| path_to_zip_file = '/content/file.zip' | |
| with zipfile.ZipFile(path_to_zip_file, 'r') as zip_ref: | |
| zip_ref.extractall(directory_to_extract_to) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def plot_confusion_matrix(cm, classes, | |
| normalize=False, | |
| title='Confusion matrix', | |
| cmap=plt.cm.Blues): | |
| """ | |
| This function prints and plots the confusion matrix. | |
| Normalization can be applied by setting `normalize=True`. | |
| """ | |
| plt.figure(figsize = (5,5)) | |
| plt.imshow(cm, interpolation='nearest', cmap=cmap) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def plot_learning_curve(history): | |
| plt.figure(figsize=(16,8)) | |
| plt.subplot(1,2,1) | |
| plt.plot(history.history['accuracy']) | |
| plt.plot(history.history['val_accuracy']) | |
| plt.title('model accuracy') | |
| plt.ylabel('accuracy') | |
| plt.xlabel('epoch') | |
| plt.legend(['train', 'Val'], loc='upper left') | |
| plt.savefig('./accuracy_curve.png') |