title: Convert a torch t7 model to keras h5
body: <p>How can we convert a t7 model to keras' h5 ?
  I am trying to do so for <strong>c3d-sports1m-kinetics.t7</strong> that you can find here <a href="https://github.com/kenshohara/3D-ResNets/releases" rel="nofollow noreferrer">https://github.com/kenshohara/3D-ResNets/releases</a></p>
  
  <p>The least I can ask for is a way to load the t7 model to python (pytorch) and then extract its weights, but I couldn't do it with the <strong>load_lua()</strong> function...</p>
  
  <p>I get an error while trying to do it using this function <a href="https://github.com/pytorch/pytorch/blob/c6529f4851bb8ac95f05d3f17dea178a0367aaee/torch/utils/serialization/read_lua_file.py" rel="nofollow noreferrer">https://github.com/pytorch/pytorch/blob/c6529f4851bb8ac95f05d3f17dea178a0367aaee/torch/utils/serialization/read_lua_file.py</a></p>
  
  <p>The error that I get is the following :</p>
  
  <pre><code>Traceback (most recent call last):
  File "convert_t7_to_hdf5.py", line 574, in &lt;module&gt;
      a = load_lua("model.t7")
    File "convert_t7_to_hdf5.py", line 571, in load_lua
      return reader.read()
    File "convert_t7_to_hdf5.py", line 542, in read
      typeidx = self.read_int()
    File "convert_t7_to_hdf5.py", line 440, in read_int
      return self._read('i')
    File "convert_t7_to_hdf5.py", line 431, in _read
      result = struct.unpack(fmt, self.f.read(sz))
  ValueError: read of closed file
  </code></pre>