You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi. First of all, thanks for writing this library. It saves me a lot of time just wrapping tensorflow code into a new function and using it as is in my pytorch projects.
This is exactly the gist of this issue: I thought we might be able to get the interface a little bit simpler so that you just literally have to wrap it into a new function.
I think it should look something like this:
deftf_function(a, b):
c=3*a+4*b*breturncsession=tf.compat.v1.Session()
f=tfpyth.wrap_torch_from_tensorflow(
tf_function, ["a", "b"], session=session
)
# or simplerf=tfpyth.wrap_torch_from_tensorflow(
tf_function, session=session
) # automatically creates placeholders for "a" and "b" inside# or even simplerf=tfpyth.wrap_torch_from_tensorflow(
tf_function
) # automatically creates placeholders for "a" and "b" and sessiona_=th.tensor(1, dtype=th.float32, requires_grad=True)
b_=th.tensor(3, dtype=th.float32, requires_grad=True)
x=f(a_, b_)
assertx==39.0x.backward()
assertnp.allclose((a_.grad, b_.grad), (3.0, 24.0))
Turns out, I already went ahead and added this exact feature. You can check it out -->here<--. I was just wondering a PR would be interesting to persue this feature.
Cheers
The text was updated successfully, but these errors were encountered:
Oh yes, this is cool! 🎉 I'm currently scramming towards some deadlines, but I'll get back to you next week.
It looks very useful. I need to think about the session singleton. I'm wary of having too much state, so it might be easier to just use tf.compat.v1.get_default_session()? Everything else could go in right away I think.
Thanks for taking a minute to respond.
I am not set on the singleton. It was just my first guess on how to prevent
multiple sessions to spawn.
I also think that ultimately, one would want to have a decorator style
functionality which reads types from type hints and creates the callable
automatically.
On Mon, Jun 8, 2020, 21:06 Andreas Kirsch ***@***.***> wrote:
Oh yes, this is cool! 🎉 I'm currently scramming towards some deadlines,
but I'll get back to you next week.
It looks very useful. I need to think about the session singleton. I'm
wary of having too much state, so it might be easier to just use
tf.compat.v1.get_default_session()? Everything else could go in right
away I think.
Thanks!
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#3 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABRXFWISN2N5GM6VVYABE4TRVUZDHANCNFSM4MIUTYRQ>
.
Hi. First of all, thanks for writing this library. It saves me a lot of time just wrapping tensorflow code into a new function and using it as is in my pytorch projects.
This is exactly the gist of this issue: I thought we might be able to get the interface a little bit simpler so that you just literally have to wrap it into a new function.
I think it should look something like this:
Turns out, I already went ahead and added this exact feature. You can check it out -->here<--. I was just wondering a PR would be interesting to persue this feature.
Cheers
The text was updated successfully, but these errors were encountered: