Skip to content

Instantly share code, notes, and snippets.

View overtunned's full-sized avatar

Abhishek Gopinath K overtunned

View GitHub Profile
@overtunned
overtunned / cPickle.py
Created November 16, 2021 13:47
cPickle dump and load
import _pickle as cPickle
cPickle.dump(train_imgids, open('filename', 'wb'))
data = cPickle.load(open('filename','rb')).tolist()
@overtunned
overtunned / unzip_colab.py
Created November 16, 2021 13:21
Unzip files in colab
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)
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)
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')