In [1]:
import sys
sys.path.append('../../')
import time
In [2]:
from library.datasets.cifar.cifar100 import CIFAR100
from library.utils import file_utils
In [3]:
total_time = 0
exp_no = 1
In [4]:
output_directory = '../../models/cifar100/load_cifar100_dataset/'
dataset_file = output_directory + 'cifar100_dataset.h5'
file_utils.mkdir_p(output_directory)
num_train_images = 1.0
In [5]:
start = time.time()
cifar100 = CIFAR100(num_images=num_train_images, save_h5py='')
end = time.time()
total_time += (end-start)
print('CIFAR10 class constructor - %.4f seconds' % (end-start))
In [6]:
start = time.time()
cifar100.load_data(data_directory='../../datasets/cifar100/')
end = time.time()
total_time += (end-start)
print('Loaded CIFAR100 dataset in %.4f seconds' % (end-start))
In [7]:
cifar100.plot_sample(plot_train=True, plot_test=False, fig_size=(14, 14))
In [8]:
cifar100.plot_images(cifar100.train.images, cifar100.train.fine_class_names,
cls_true_coarse=cifar100.train.coarse_class_names,
nrows=3, ncols=3, fig_size=(14,14), fontsize=15, convert=False, type='rgb')
Out[8]:
In [9]:
cifar100.plot_sample(plot_train=False, plot_test=True)
In [10]:
cifar100.plot_images(cifar100.test.images, cifar100.test.fine_class_names,
cls_true_coarse=cifar100.test.coarse_class_names,
nrows=3, ncols=3, fig_size=(14,14), fontsize=15, convert=False, type='rgb')
Out[10]:
In [ ]:
def output_HTML(read_file, output_file):
from nbconvert import HTMLExporter
import codecs
import nbformat
exporter = HTMLExporter()
output_notebook = nbformat.read(read_file, as_version=4)
print()
output, resources = exporter.from_notebook_node(output_notebook)
codecs.open(output_file, 'w', encoding='utf-8').write(output)
In [ ]:
%%javascript
var notebook = IPython.notebook
notebook.save_notebook()
In [ ]:
%%javascript
var kernel = IPython.notebook.kernel;
var thename = window.document.getElementById("notebook_name").innerHTML;
var command = "theNotebook = " + "'"+thename+"'";
kernel.execute(command);
In [ ]:
current_file = './' + theNotebook + '.ipynb'
output_file = output_directory + 'exp_no_' + str(exp_no).zfill(2) + '_' + theNotebook + '.html'
print('Current file: ' + str(current_file))
print('Output file: ' + str(output_file))
file_utils.mkdir_p(output_directory)
output_HTML(current_file, output_file)
In [ ]:
print('Code took %.6f s to run on training with %d examples' % (total_time,num_train_images))
In [ ]: