lesterpjy / numeric-t5 Goto Github PK
View Code? Open in Web Editor NEWTraining T5 to perform numerical reasoning.
License: MIT License
Training T5 to perform numerical reasoning.
License: MIT License
Hi,
I'd like to read in the model and convert it to PyTorch.
I use the following code snippet to read in the weights:
from transformers import T5Tokenizer, TFT5ForConditionalGeneration
tokenizer = T5Tokenizer.from_pretrained('t5-small')
model = TFT5ForConditionalGeneration.from_pretrained('t5-small')
model.compile()
model.load_weights("/content/drive/MyDrive/NT5/Checkpoints/model_chkpt_e_42_vl_0.04173539.h5")
The checkpoint is stored in my local Drive.
However, this is giving me the following error:
All model checkpoint layers were used when initializing TFT5ForConditionalGeneration.
All the layers of TFT5ForConditionalGeneration were initialized from the model checkpoint at t5-small.
If your task is similar to the task the model of the checkpoint was trained on, you can already use TFT5ForConditionalGeneration for predictions without further training.
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-5-afea930cf1a9> in <module>()
4 model = TFT5ForConditionalGeneration.from_pretrained('t5-small')
5 #model.compile()
----> 6 model.load_weights("/content/drive/MyDrive/NT5/Checkpoints/model_chkpt_e_42_vl_0.04173539.h5")
1 frames
/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/engine/training.py in load_weights(self, filepath, by_name, skip_mismatch, options)
2232 f, self.layers, skip_mismatch=skip_mismatch)
2233 else:
-> 2234 hdf5_format.load_weights_from_hdf5_group(f, self.layers)
2235
2236 def _updated_config(self):
/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/saving/hdf5_format.py in load_weights_from_hdf5_group(f, layers)
686 'containing ' + str(len(layer_names)) +
687 ' layers into a model with ' + str(len(filtered_layers)) +
--> 688 ' layers.')
689
690 # We batch weight value assignments in a single backend call
ValueError: You are trying to load a weight file containing 4 layers into a model with 3 layers.
How to resolve this?
Notebook to reproduce: https://colab.research.google.com/drive/1vVORlnUAv1Tre71gEoh14C1fZvig0Vd1?usp=sharing
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.