CNNresultsAnalysis


Lung nodule CNN analysis


In [1]:
import numpy as np
import pandas as pd

import matplotlib.pyplot as plt
import seaborn as sns 

import tflearn
import h5py

from PIL import Image

from scipy.misc import imread

%matplotlib inline
from IPython.display import clear_output
pd.options.mode.chained_assignment = None

In [2]:
import sys
sys.path.append('../src/models/')
from cnn_model import CNNModel

In [3]:
h5f2 = h5py.File('../src/data/test.h5', 'r')
X_test_images = h5f2['X']
Y_test_labels = h5f2['Y']
h5f2.close()

h5f = h5py.File('../src/data/train.h5', 'r')
X_train_images = h5f['X']
Y_train_labels = h5f['Y']
h5f.close()

In [4]:
## Model definition
convnet  = CNNModel()
network = convnet.define_network(X_train_images)
model = tflearn.DNN(network)
model.load("nodule-classifier.tfl")
predictions = model.predict(X_test_images[:,:,:,:])
score = model.evaluate(X_test_images, Y_test_labels)


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-4-ac3bc8e0a44a> in <module>()
      1 ## Model definition
      2 convnet  = CNNModel()
----> 3 network = convnet.define_network(X_train_images)
      4 model = tflearn.DNN(network)
      5 model.load("nodule-classifier.tfl")

/Volumes/LittleOne/Insight/LungCancerProject/LungNoduleCNN/src/models/cnn_model.py in define_network(self, X_images)
    116 
    117 		"""
--> 118                 self.input_layer(X_images)
    119                 self.convolution_layer(50, 3, 'relu') # 50 filters, with size 3
    120                 self.max_pooling_layer(2) # downsamples spatial size by 2

/Volumes/LittleOne/Insight/LungCancerProject/LungNoduleCNN/src/models/cnn_model.py in input_layer(self, X_images)
     51                 img_prep = self.preprocessing()
     52                 img_aug = self.augmentation()
---> 53 		self.network = input_data(shape = [None, X_images.shape[1], X_images.shape[2], X_images.shape[3]],
     54                      data_preprocessing = img_prep,
     55                      data_augmentation = img_aug)

h5py/_objects.pyx in h5py._objects.with_phil.wrapper (/Users/travis/miniconda3/conda-bld/work/h5py-2.6.0/h5py/_objects.c:2840)()

h5py/_objects.pyx in h5py._objects.with_phil.wrapper (/Users/travis/miniconda3/conda-bld/work/h5py-2.6.0/h5py/_objects.c:2798)()

/Users/nemo/anaconda/envs/kaggleShit/lib/python2.7/site-packages/h5py/_hl/dataset.pyc in shape(self)
    211     def shape(self):
    212         """Numpy-style shape tuple giving dataset dimensions"""
--> 213         return self.id.shape
    214     @shape.setter
    215     @with_phil

h5py/h5d.pyx in h5py.h5d.DatasetID.shape.__get__ (/Users/travis/miniconda3/conda-bld/work/h5py-2.6.0/h5py/h5d.c:2771)()

h5py/h5d.pyx in h5py.h5d.DatasetID.shape.__get__ (/Users/travis/miniconda3/conda-bld/work/h5py-2.6.0/h5py/h5d.c:2691)()

h5py/_objects.pyx in h5py._objects.with_phil.wrapper (/Users/travis/miniconda3/conda-bld/work/h5py-2.6.0/h5py/_objects.c:2840)()

h5py/_objects.pyx in h5py._objects.with_phil.wrapper (/Users/travis/miniconda3/conda-bld/work/h5py-2.6.0/h5py/_objects.c:2798)()

h5py/h5d.pyx in h5py.h5d.DatasetID.get_space (/Users/travis/miniconda3/conda-bld/work/h5py-2.6.0/h5py/h5d.c:4421)()

ValueError: Not a dataset (Not a dataset)

In [ ]: