Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tf-keras functions doesn't work #86

Closed
maifeeulasad opened this issue Nov 12, 2022 · 4 comments
Closed

tf-keras functions doesn't work #86

maifeeulasad opened this issue Nov 12, 2022 · 4 comments
Assignees

Comments

@maifeeulasad
Copy link

maifeeulasad commented Nov 12, 2022

I was trying to generate latex quickly from my python code, but it didn't return the output as expected.

Code:

import latexify
import tensorflow.keras.backend as K

@latexify.with_latex
def dice_coef(y_true, y_pred, smooth = 1):
    y_true_f = K.flatten(y_true)
    y_pred_f = K.flatten(y_pred)
    intersection = K.sum(y_true_f * y_pred_f)
    return (2. * intersection + smooth) / (K.sum(y_true_f) + K.sum(y_pred_f) + smooth)



print(dice_coef)
dice_coef

latexify_py doesn't work with tensorflow or keras

@odashi odashi added the feature label Nov 12, 2022
@odashi odashi added this to the v0.3 milestone Nov 12, 2022
@odashi
Copy link
Collaborator

odashi commented Nov 12, 2022

@maifeeulasad Thanks for reporting the issue!

Since the current implementation is different from the released version(v0.1.1), I also tried the function above using the main:

無題

I guess some problems are already fixed (in main), but following things are still remaining:

  • Long name variables: Tracked by Fine-grained name processing #82.
  • The prefix K: I think we need some additional config to inform about prefixes that should be trimmed.

Note that Latexify can't recognize import aliases by only seeing the wrapped function due to the limitation of parsing. We hard-coded automated trimming for only math, numpy, and np, but increasing the number of hard-coded prefixes (especially trivial names like K) may be unsafe.

@odashi
Copy link
Collaborator

odashi commented Nov 12, 2022

I also think automatically collecting imported modules through globals() could work. Let me make another issue for it.

@odashi odashi self-assigned this Nov 12, 2022
@odashi odashi removed this from the v0.3 milestone Nov 12, 2022
@maifeeulasad
Copy link
Author

Awesome. Eagerly waiting for the updated version.

Will use main branch of this repo to generate latex for now.

@odashi
Copy link
Collaborator

odashi commented Nov 15, 2022

FYI: v0.2.0 has been released. I'd close this issue, but feel free to reopen it if you have more questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants