Create a tar file which contains the model.

    Parameters
    ----------
    matrices : list
    tarname : str
        Target file which will be created.

def create_model_tar(matrices, tarname="model-cuda-converted.tar"):
    """
    Create a tar file which contains the model.

    Parameters
    ----------
    matrices : list
    tarname : str
        Target file which will be created.
    """
    # Write layers
    filenames = []
    for layer in range(len(matrices)):
        if matrices[layer]['name'] == 'W':
            weights = matrices[layer]['storage']
            weights_file = h5py.File('W%i.hdf5' % (layer / 2), 'w')
            weights_file.create_dataset(weights_file.id.name, data=weights)
            weights_file.close()
            filenames.append('W%i.hdf5' % (layer / 2))
        elif matrices[layer]['name'] == 'b':
            b = matrices[layer]['storage']
            bfile = h5py.File('b%i.hdf5' % (layer / 2), 'w')
            bfile.create_dataset(bfile.id.name, data=b)
            bfile.close()
            filenames.append('b%i.hdf5' % (layer / 2))

        # activation = a['layers'][layer]['_props']['activation']
        # activation = activation.replace('sigmoid', 'Sigmoid')
        # activation = activation.replace('softmax', 'Softmax')
        # layers.append({'W': {'size': list(W.shape),
        #                      'filename': 'W%i.hdf5' % layer},
        #                'b': {'size': list(b.shape),
        #                      'filename': 'b%i.hdf5' % layer},
        #                'activation': activation})
    with tarfile.open(tarname, "w:") as tar:
        for name in filenames:
            tar.add(name)

    # Remove temporary files which are now in tar file
    for filename in filenames:
        os.remove(filename)