blackhc / tfpyth Goto Github PK
View Code? Open in Web Editor NEWPutting TensorFlow back in PyTorch, back in TensorFlow (differentiable TensorFlow PyTorch adapters).
License: MIT License
Putting TensorFlow back in PyTorch, back in TensorFlow (differentiable TensorFlow PyTorch adapters).
License: MIT License
How to support multiple outputs in the module
like
y,z=M(x)
can i use function defined in pytorch, such as nn.Conv2d inTensorFlow? or just operation?
I want to recall a class coding by pytorch in tensorflow, but i just found the way that how to use function.
Is it same when recalling a class? Especially the '__call__' attribution in the class has been overwritten?
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:
def tf_function(a, b):
c = 3 * a + 4 * b * b
return c
session = tf.compat.v1.Session()
f = tfpyth.wrap_torch_from_tensorflow(
tf_function, ["a", "b"], session=session
)
# or simpler
f = tfpyth.wrap_torch_from_tensorflow(
tf_function, session=session
) # automatically creates placeholders for "a" and "b" inside
# or even simpler
f = tfpyth.wrap_torch_from_tensorflow(
tf_function
) # automatically creates placeholders for "a" and "b" and session
a_ = th.tensor(1, dtype=th.float32, requires_grad=True)
b_ = th.tensor(3, dtype=th.float32, requires_grad=True)
x = f(a_, b_)
assert x == 39.0
x.backward()
assert np.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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.