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

Slightly more efficient fully-connected layer #235

Closed
m-usama-z opened this issue Aug 7, 2024 · 1 comment
Closed

Slightly more efficient fully-connected layer #235

m-usama-z opened this issue Aug 7, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@m-usama-z
Copy link

m-usama-z commented Aug 7, 2024

Hi. I suggest changing the following piece of code in the reach_star_single_input function of the FullyConnectedLayer.m class

                V(1, 1, :, in_image.numPred + 1) = zeros(obj.OutputSize, 1, 'like', in_image.V);
                for i=1:n+1
                    I = in_image.V(:,:,:,i);
                    I = reshape(I,N,1); % flatten input
                    if i==1
                        V(1, 1,:,i) = obj.Weights*I + obj.Bias;
                    else
                        V(1, 1,:,i) = obj.Weights*I;
                    end
                end

to this:

                V(1, 1, :, :) = obj.Weights*reshape(in_image.V, N, n + 1);
                V(1, 1, :, 1) = reshape(V(1, 1, :, 1), obj.OutputSize, 1) + obj.Bias;

in order to improve efficiency for a large number of generators, for both cpu and gpu modes.

@mldiego mldiego added the enhancement New feature or request label Aug 20, 2024
@mldiego
Copy link
Collaborator

mldiego commented Sep 25, 2024

Added this implementation in #243

@mldiego mldiego closed this as completed Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants