-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
DeepOnet Multiple output #9
Comments
With |
We need embbeding_size = 10
branch = Lux.Chain(
Lux.Dense(3, 20, Lux.tanh_fast),
Lux.Dense(20, 20, Lux.tanh_fast),
Lux.Dense(20, embbeding_size))
a = rand(3, 50,40, 1)
θ, st = Lux.setup(Random.default_rng(), branch)
b_out, st = branch(a, θ, st)
trunk = Lux.Chain(
Lux.Dense(2, 20, Lux.tanh_fast),
Lux.Dense(20, 20, Lux.tanh_fast),
Lux.Dense(20, embbeding_size, Lux.tanh_fast))
a = rand(2, 1, 1, 30)
θ, st = Lux.setup(Random.default_rng(), trunk)
t_out, st = branch(a, θ, st)
out_ = b_out .* t_out;
# julia > size(out_)
# (embbeding_size, 50, 40, 30)
# here we sum embbeding inner representation
out = sum(out_ , dims = 1)
# julia > size(out)
# (1, 50, 40, 30)
output_size = 3
linear = Lux.Dense(10, output_size)
θ, st = Lux.setup(Random.default_rng(), linear)
l_out, st = linear(out_, θ, st)
#julia > size(l_out)
#(output_size, 50, 40, 30) ps Option for the layer at the end can be used for many other purposes (for example Fourier feature embeddings an many other) not only for the multi output that I described here as issue. So in generally I think it will be good thing for interface. |
Hi @KirillZubov, In case of multiple outputs, The input of the branch net is then a vector. For a batch size of The output of branch net would then be This is how I understand the DeepONets work. If this is correct, the |
I've quite fast written this script above just only for show how to use linear layer. My point here is not about how to calculate the vector inside. It is about support multiple output for DeepOnet. If you think that isn't need here - ok. Yes we can use batch of NNs for each output independently but also can use one NN for all output. Here example https://github.com/SciML/NeuralPDE.jl/blob/a57b966df8e172f7e0eebf9ec0c2d94b6eaf596e/test/NNODE_tests.jl#L137-L153 DeepOnet is not about what size vectors. It about how to learn operator from sensor and locations information with branch-trunk architecture, other is flexible. It would be better to strive to make an implementation that could work with the widest possible range of extensions and not be strictly limited. |
I can implement this feature myself by the way. |
I see. The
We can probably use the |
Why do you want use |
Hi,
This works when the broadcasting dimensions are same, which as we see here, won't always be true. I think I finally got the high dimensional case. We have a function Let's have
We leave it to the user to determine how to transform
There is also a restriction on the dimensions of the outputs from the trunk, unless it implies that the user should take care of the dimensions of the trunk. While it is reasonable, because we can have any representation of the latent state where we do the dot product, but then the reshape at |
ok, got it |
u = rand(Float32, 64, 2, 5) # m x u_dims x nb
y = rand(Float32, 6, 40, 5) # ndims x N x nb To solve this do it on a case by case basis:
|
Now the output only for one feature solution with dropping one dim (1, 10, 5) to (10, 5). It is not dim for multiple output.
It need additional dim
(output_dim, 10, 5)
My suggestion and easy way is add linear layer as option, how it has done here
src/neural_operators.jl
SciML/NeuralPDE.jl@30a5134#diff-3623c72624d6f36cc808e510588bfe6ed4872162fdce6e12b69408856c038c5dThe text was updated successfully, but these errors were encountered: