-
Notifications
You must be signed in to change notification settings - Fork 110
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
Implicit broadcast harmful? #135
Comments
You are correct but But as the Tensors are not julia arrays, but representations of points in the computation graph, It may be that mean that |
I think the best we can really do with the changes in .6 is to define the scalar-form operators ( Longer-term, I'm thinking of having a macro like |
Why couldn't you solve this by defining |
So rather the defining
just define broadcast once for all functions. as Base.broadcast(func::Function, t1::AbstractTensor, ts...; kwargs...) = func(t1, Tensor.(ts)...; kwargs...)
Base.broadcast(func::Function, t1::AbstractTensor, t2::AbstractTensor, ts...; kwargs...) = func(t1, t2, Tensor.(ts)...; kwargs...)
Base.broadcast(func::Function, t1, t2::AbstractTensor, ts...; kwargs...) = func(Tensor(t1), t2, Tensor.(ts)...; kwargs...) |
I'm not sure that's quite what we want...we need |
Can't you define a generic Basically, |
Not quite sure I see how a custom TensorFlow op helps with the situation - there is already one TensorFlow op for matrix multiplication and a TensorFlow op for element-wise multiplication, it's just a matter of the syntax for exposing them to users. Users probably expect |
It is going to break this code Which is sad, because that is some beautiful duck-typing, Being able to duck-type Tensors as Arrays is one of the most wonderful features. |
I guess a workaround for now is to introduce an operator like ⊛ that is element-wise multiplication for both tensors and arrays and use that in TensorFlowDiffEq. |
Because then you can define |
Closing as non-actionable/already fixed |
I'm posting this as an issue but intend it as a suggestion you might consider.
In Julia, operators such as
+,-
that work elementwise on matrices and vectors do not automatically broadcast when dimensions of the two operands are not the same, for this, the dot-syntax (e.g.,.+
) must be used. I find this explicit broadcast a nice safety feature.Tensorflow operations, such as the ones above, use implicit broadcast, i.e., if dimensions do not match, broadcast is considered.
I'm proposing the following: In
Tensorflow.jl
, the dot syntax automatically calls the corresponding tensorflow operation, but the dot-free syntax throws an error if the sizes of the operands do not match.Any thoughts on this? :)
The text was updated successfully, but these errors were encountered: