Comments (5)
@roebius - this is most likely an issue with keras and dict outputs - internally in tf.keras the dict is flattened to a list, and the order might get changed. I thought until now that the order in this case is alphabetical (and would be interested to understand why that's not the case - I believe it is different between TF versions; I also have issued a different but related bug to the TF team - tensorflow/tensorflow#34199).
I don't think it is an issue with bert-for-tf2. I guess you are using BertModelLayer
which is just a layer (not aware of the "outer" keras model populating the outputs). You could easily replace it with an EmbeddingLayer
and see, if the keras behavior will change.
from bert-for-tf2.
@roebius - (edit: I believe it is name of the output tensor that counts not the dictionary entry ) - it is the dict key that counts (but it didn't worked right with a loss dict, therefore I've switched to using list outputs instead).
I'm using a:
ident = lambda n: tf.keras.layers.Lambda(lambda a: a, name=n)
outputs = [ident("output-a")(out_a), ident("output-b")(out_b)]
to force the names on the output tensors.
from bert-for-tf2.
Thank you for your reply and suggestions.
I confirm I am using BertModelLayer
. I also believe it is a Keras issue, but it is a bit complicated for me to change the output layer names: some TF ops I am using force name prefixes for the output layers, so I have to use the actual layer names for my losses but I have to use different names in the output dictionary for the TFRecords I am feeding.
(sorry that I cannot attach a schema as I am not allowed by the rules of a competition I am taking part in :(
from bert-for-tf2.
@roebius - changing the output names can be done with the ident
function/layer above. But if I remember correctly it is relevant for the model losses only.
from bert-for-tf2.
I was eventually able to solve the issue.
For the model creation, I am passing the outputs as a list instead of a dictionary: this way the prediction outputs are not switched anymore.
Thanks to your ident
suggestion I was able to refactor my code in order to use the output layer names consistently between model output, model losses and TFRecord feature mapping when feeding the model for fit/predict.
Many thanks again.
from bert-for-tf2.
Related Issues (20)
- ResourceExhaustedError: OOM when allocating tensor with shape[501153,768] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfc [Op:Mul]
- mixed precision HOT 3
- example (gpu_movie_reviews) has some mistake
- Failed to get weights from pretrained google model HOT 2
- Can not load pretrained bert weights when loading chinese_L-12_H-768_A-12/bert_model.ckpt HOT 3
- Paddings must be non-negative
- albert classification error(Failed copying input tensor from GPU in order to run Identity: GPU sync failed [Op:Identity])
- ValueError: Found unexpected keys that do not correspond to any Model output
- More comments for the code
- Can't train BERT with loaded weights on QA Task HOT 3
- Setting unexpected parameter 'name' in Params instance 'Params' HOT 2
- how to using this in functional model
- may be there is some problem work with tf hub
- AttributeError: module 'bert' has no attribute 'Layer'
- type error HOT 5
- Activation after bert-layer differs
- Count of weight not found[196]
- OSS License compatibility question
- tensorflow.python.keras.layer.input_spec should be replaced with tensorflow.keras.layers.InputSpec HOT 1
- setuptools.convert_path removed
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bert-for-tf2.