In [1]:
import sys
sys.path.append('../../')
import time
In [2]:
from library.datasets.cifar.cifar10 import CIFAR10
from library.utils import file_utils
In [3]:
total_time = 0
exp_no = 1
In [4]:
output_directory = '../../models/cifar10/load_cifar10_dataset/'
dataset_file = output_directory + 'cifar10_dataset.h5'
file_utils.mkdir_p(output_directory)
num_train_images = 1.0
In [5]:
start = time.time()
cifar10 = CIFAR10(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()
cifar10.load_data(data_directory='../../datasets/cifar10/')
end = time.time()
total_time += (end-start)
print('Loaded CIFAR10 dataset in %.4f seconds' % (end-start))
In [7]:
cifar10.plot_sample(plot_train=True, plot_test=False)
In [9]:
cifar10.plot_images(cifar10.train.images, cifar10.train.fine_class_names, cls_pred_fine=None, nrows=3, ncols=3,
fig_size=(7,7), fontsize=15, convert=False, type='rgb')
Out[9]:
In [10]:
cifar10.plot_sample(plot_train=False, plot_test=True)
In [12]:
cifar10.plot_images(cifar10.test.images, cifar10.test.fine_class_names, cls_pred_fine=None, nrows=3, ncols=3,
fig_size=(7,7), fontsize=15, convert=False, type='rgb')
Out[12]:
In [13]:
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 [14]:
%%javascript
var notebook = IPython.notebook
notebook.save_notebook()
In [15]:
%%javascript
var kernel = IPython.notebook.kernel;
var thename = window.document.getElementById("notebook_name").innerHTML;
var command = "theNotebook = " + "'"+thename+"'";
kernel.execute(command);
In [16]:
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 [17]:
print('Code took %.6f s to run on training with %d examples' % (total_time,num_train_images))
In [ ]: