title: I'm Trying to Get Keras to Load vgg16.h5 Wheights Locally Instead of Downloading
body: <p>I've tried modifying this code serveral different ways,<br>
  from trying to change the last lines to my vgg16.h5 file on my local disk,<br>
  to importing load_weights from Keras and trying to get it to grab the weights that way instead.  </p>
  
  <p>This code is from lesson 1 of the fast.ai course. I've asked on their forum but got no response.  </p>
  
  <p>The files running this are in this link.<br>
  <a href="https://github.com/fastai/courses/tree/master/deeplearning1/nbs" rel="nofollow noreferrer">https://github.com/fastai/courses/tree/master/deeplearning1/nbs</a><br>
  lesson1.ipynb calls on the file vgg16.py to download the weights.<br>
  The code below starts at line 117 in the vgg16.py file.  </p>
  
  <pre><code>def create(self):
      """
          Creates the VGG16 network achitecture and loads the pretrained weights.
          Args:   None
          Returns:   None
      """
      model = self.model = Sequential()
      model.add(Lambda(vgg_preprocess, input_shape=(3,224,224), output_shape=(3,224,224)))
  
      self.ConvBlock(2, 64)
      self.ConvBlock(2, 128)
      self.ConvBlock(3, 256)
      self.ConvBlock(3, 512)
      self.ConvBlock(3, 512)
  
      model.add(Flatten())
      self.FCBlock()
      self.FCBlock()
      model.add(Dense(1000, activation='softmax'))
  
      fname = 'vgg16.h5'
      model.load_weights(get_file(fname, self.FILE_PATH+fname, cache_subdir='models'))
  </code></pre>
  
  <p>The above code is the code out of the box that downloads the weights.<br>
  When I change that last line and get rid of everything in the parenthesis except for 'fname' like this...  </p>
  
  <pre><code>    fname = 'vgg16.h5'  
      model.load_weights(fname)
  </code></pre>
  
  <p>I get the error below.  </p>
  
  <pre><code>---------------------------------------------------------------------------
  InternalError                             Traceback (most recent call last)
  &lt;ipython-input-7-2b6861506a11&gt; in &lt;module&gt;()
  ----&gt; 1 vgg = Vgg16()
        2 # Grab a few images at a time for training and validation.
        3 # NB: They must be in subdirectories named based on their category
        4 batches = vgg.get_batches(path+'train', batch_size=batch_size)
        5 val_batches = vgg.get_batches(path+'valid', batch_size=batch_size*2)
  
  /home/eagle/fastai/courses-master/deeplearning1/nbs/vgg16.pyc in __init__(self)
       45     def __init__(self):
       46         self.FILE_PATH = 'http://files.fast.ai/models/'
  ---&gt; 47         self.create()
       48         self.get_classes()
       49 
  
  /home/eagle/fastai/courses-master/deeplearning1/nbs/vgg16.pyc in create(self)
      137 
      138         fname = 'vgg16.h5'
  --&gt; 139         model.load_weights(fname)
      140 
      141 
  
  /home/eagle/anaconda3/envs/les1/lib/python2.7/site-packages/Keras-1.2.2-py2.7.egg/keras/engine/topology.pyc in load_weights(self, filepath, by_name)
     2706             self.load_weights_from_hdf5_group_by_name(f)
     2707         else:
  -&gt; 2708             self.load_weights_from_hdf5_group(f)
     2709 
     2710         if hasattr(f, 'close'):
  
  /home/eagle/anaconda3/envs/les1/lib/python2.7/site-packages/Keras-1.2.2-py2.7.egg/keras/engine/topology.pyc in load_weights_from_hdf5_group(self, f)
     2792                         weight_values[0] = w
     2793                 weight_value_tuples += zip(symbolic_weights, weight_values)
  -&gt; 2794             K.batch_set_value(weight_value_tuples)
     2795 
     2796     def load_weights_from_hdf5_group_by_name(self, f):
  
  /home/eagle/anaconda3/envs/les1/lib/python2.7/site-packages/Keras-1.2.2-py2.7.egg/keras/backend/tensorflow_backend.pyc in batch_set_value(tuples)
     1879             assign_ops.append(assign_op)
     1880             feed_dict[assign_placeholder] = value
  -&gt; 1881         get_session().run(assign_ops, feed_dict=feed_dict)
     1882 
     1883 
  
  /home/eagle/anaconda3/envs/les1/lib/python2.7/site-packages/Keras-1.2.2-py2.7.egg/keras/backend/tensorflow_backend.pyc in get_session()
      120                 config = tf.ConfigProto(intra_op_parallelism_threads=nb_thread,
      121                                         allow_soft_placement=True)
  --&gt; 122             _SESSION = tf.Session(config=config)
      123         session = _SESSION
      124     if not _MANUAL_VAR_INIT:
  
  /home/eagle/anaconda3/envs/les1/lib/python2.7/site-packages/tensorflow/python/client/session.pyc in __init__(self, target, graph, config)
     1191 
     1192     """
  -&gt; 1193     super(Session, self).__init__(target, graph, config=config)
     1194     # NOTE(mrry): Create these on first `__enter__` to avoid a reference cycle.
     1195     self._default_graph_context_manager = None
  
  /home/eagle/anaconda3/envs/les1/lib/python2.7/site-packages/tensorflow/python/client/session.pyc in __init__(self, target, graph, config)
      552     try:
      553       with errors.raise_exception_on_not_ok_status() as status:
  --&gt; 554         self._session = tf_session.TF_NewDeprecatedSession(opts, status)
      555     finally:
      556       tf_session.TF_DeleteSessionOptions(opts)
  
  /home/eagle/anaconda3/envs/les1/lib/python2.7/contextlib.pyc in __exit__(self, type, value, traceback)
       22         if type is None:
       23             try:
  ---&gt; 24                 self.gen.next()
       25             except StopIteration:
       26                 return
  /home/eagle/anaconda3/envs/les1/lib/python2.7/site-packages/tensorflow/python/framework/errors_impl.pyc in raise_exception_on_not_ok_status()
      464           None, None,
      465           compat.as_text(pywrap_tensorflow.TF_Message(status)),
  --&gt; 466           pywrap_tensorflow.TF_GetCode(status))
      467   finally:
      468     pywrap_tensorflow.TF_DeleteStatus(status)
  
  InternalError: Failed to create session.
  </code></pre>