Comments (6)
I think the way we're trying to go is trax.layers.Fn('MyLoss', loss_fn)
- Fn
is just Lambda
. Thanks for your help as we try to make it understandable - we need to improve the docs too!
Closing for now as the immediate issue is resolved.
from trax.
Let me look into this, but if possible can you send a repro? Is the problem in 1.2.4 or earlier?
from trax.
This was changed on purpose in 1.2.4 so as to make sure losses are indeed just layers. A quick fix here is just making it CrossEntropyLoss().
But let's think if the quick fix is enough. Stefan: do you have a use-case where having functions-creating-layers instead of layer instances is actually desireable?
from trax.
Hi! :)
I only intended to point this out. E.g. is the naming loss_fn
a bit misleading. Also the old examples are passing only the type loss_fn=trax.layers.CrossEntropyLoss
instead of the object.
@afrozenator The problem starts with 1.2.4 and it's easy to reproduce by just passing something that is not a layer to loss_fn
from trax.
Thanks for pointing this out! I agree the naming is now misleading - and sorry for the incompatibility! But if there's no reason to have function there, we should probably go with just having layers and maybe just calling it loss? Thanks for bringing this to our attention!
from trax.
You're welcome. No big deal - in cases like this exceptions are rather clear and one can figure out what to do :) Regarding the argument: I really know too little at this point about trax to be able to say what makes sense but one idea would be to do like Keras when compiling the model (see docs):
Arguments:
- loss: String (name of objective function), objective function or tf.keras.losses.Loss instance. See tf.keras.losses. An objective function is any callable with the signature scalar_loss = fn(y_true, y_pred). If the model has multiple outputs, you can use a different loss on each output by passing a dictionary or a list of losses. The loss value that will be minimized by the model will then be the sum of all individual losses.
But of course that will make the implementation of Trainer
a bit more complex.
One advantage of functions could be that I can just provide a function in cases where I already have one in my code. Also I don't need to write a wrapper-object for such a function or any function which does not require data or a state during execution.
After all I would say this is a design question. We can always have a trax.layers.LambdaLoss
as in LambdaLoss(loss_fn=my_loss_fn)
to provide a simple wrapper.
Thanks for bringing this to our attention!
I say thanks for sharing t2t and trax with us :)
from trax.
Related Issues (20)
- The colab button on Knowledge_Tracing_Transformer.ipynb is not open
- TypeError: float() argument must be a string or a number, not 'jaxlib.tpu_client_extension.PyTpuBuffer'
- Machine Translation Refromer model.pkl for trax 1.4.1?
- ImportError: cannot import name 'MergeHeads' from 'trax.layers.attention'
- how to use trax to translate other languages
- Limit the dataset from TFDS
- TypeError: unsupported operand type(s) for ==: 'Array' and 'tuple' HOT 2
- SelfAttention - problem with tensorflow 2.11.0
- AttributeError: module 'jax.ops' has no attribute 'index_add' HOT 1
- Unable to import trax HOT 1
- Cannot import Trax HOT 6
- Could not normally run trax using GPU in local computer
- Issue when running training_loop.run(2000) - message StopIteration in next_batch(self)
- Is possible Linformer algorithm ?
- Can I do simple tokenization?
- Can't run `bert_vocab_from_dataset` without `TypeError: Tensor is unhashable` when import `trax` with `tensorflow`
- Are any easy ways to use something like `train_test_split` from `sklearn`?
- AttributeError: 'function' object has no attribute 'n_steps_per_checkpoint' for NLP Machine translation model HOT 1
- Error loading loop from a checkpoint HOT 1
- Inconsistency in function's doc-string HOT 1
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 trax.