Accessing ULMFiT pre-trained model

(Rishabh Choudhary) #1

I am following this tutorial: https://github.com/fastai/fastai/tree/master/courses/dl2/imdb_scripts

I downloaded the pre-trained model in part 3b.
I want to open the .h5 files and look/use the weights. I tried to use python to do this, but it is not opening.

Here’s the code I used:
import tables
import pandas as pd
filename = “…bwd_wt103.h5”
file = tables.open_file(filename)

Here’s the error:
OSError: HDF5 error back trace
File “C:\ci\hdf5_1525883595717\work\src\H5F.c”, line 511, in H5Fopen
unable to open file
File “C:\ci\hdf5_1525883595717\work\src\H5Fint.c”, line 1604, in H5F_open
unable to read superblock
File “C:\ci\hdf5_1525883595717\work\src\H5Fsuper.c”, line 413, in H5F__super_read
file signature not found

End of HDF5 error back trace

Unable to open/create file 'C:/Users/Rishabh/Documents/School and Work/Classes/8 
Fall2019/Senior Design/ULMFiT/Wiki Data/wt103/models/bwd_wt103.h5'

I also used The HDF Group HDF Viewer: https://support.hdfgroup.org/products/java/release/download.html

But that didn’t work either. It gave an error saying “Failed to open the file… Unsupported format”

Is there a way to load the weights in Python? I ultimately want to access the last layer of the stacked LSTMS to create word embeddings.

Thanks in advance.

0 Likes