Comments (4)
Hi! First, here's a proper converter:
@converter(F.log_softmax, torch.log_softmax, torch.Tensor.log_softmax, channel_ordering_strategy=ChannelOrderingStrategy.MINIMUM_TRANSPOSITIONS)
def converter_log_softmax(input: Tensor, dim, *, dtype: Optional[_dtype]=None):
num_dims = input.dim()
def func(input, dim, *, dtype=None):
if get_channel_order(input) == ChannelOrder.TENSORFLOW:
dim = dim_pytorch2keras(dim, num_dims)
return tf.nn.log_softmax(input, axis=dim)
return func
Turns out, the converter is already there, and I registered it for torch.log_softmax
, torch.Tensor.log_softmax
, but forgot about F.log_softmax
.
Your implementation does not work correctly because due to ChannelOrderingStrategy.MINIMUM_TRANSPOSITIONS
it can receive input tensor in channel-last layout, and in this case, dim
has to be adapted accordingly.
The dim < 0
check is redundant, as it's done inside dim_pytorch2keras
. Output type cast can also be omitted, because if needed, its' performed automatically inside the wrapper layer.
from nobuco.
Awesome, thanks! Got lightglue built, and I think it is working... want any of these chatgpt-sourced converters?
coxep@5afcdf0
from nobuco.
Awesome, thanks! Got lightglue built, and I think it is working... want any of these chatgpt-sourced converters? coxep@5afcdf0
Yep, I'll take it.
A word of warning: there's a good chance the model was not converted properly. See, LightGlue is quite dynamic, the number of iterations depends on the difficulty of the task, and Nobuco cannot automatically capture control flows. It might still work as-is, but you'd be missing out on performance. Speaking of performance. Tensorflow lags behind Pytorch considerably when it comes to transformers. Pytorch already integrated fast attention operations (notably, F.scaled_dot_product_attention
), and there's no such thing in TFLite.
from nobuco.
Thanks for the heads-up. I'm guessing that the conversion was suboptimal. The h5 file is ~80mb, but I'm at least getting the same correspondence as the pytorch model.
I did have to make some changes (disabled pruning, fixed the number of iterations / disabled early stopping, etc)
from nobuco.
Related Issues (20)
- Add support for multidimensional aggregating function HOT 1
- TensorFlow 2 PyTorch? HOT 7
- Custom initializer for tf weights HOT 6
- Much slower training after convert torch code to tf code HOT 1
- LogSoftMax conversion HOT 1
- How to llama 2 conversion HOT 1
- Add support for torch.repeat_interleave HOT 2
- unnecessary python 3.9 limitation HOT 1
- Tensorflow warns that variables were used in Lambda layers but are not present in tracked objects HOT 2
- I am getting 'Unimplemented nodes' exception HOT 5
- Keras symbolic inputs/outputs do not implement `__len__` HOT 8
- Custom Softplus Layer and Einsum Error when load_model with Keras HOT 7
- Debugging tensor shapes when using dynamic axes HOT 8
- Convolution layers: Add support for `same` padding. HOT 2
- Parameter count mismatch when converting `nn.TransformerEncoderLayer` HOT 6
- [Question] Are dynamic axes supported? HOT 2
- TypeError: converter_mean() got an unexpected keyword argument 'keepdims' HOT 2
- Thank you for releasing this wonderful repository. HOT 2
- pytorch version? 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 nobuco.