Git Product home page Git Product logo

Comments (6)

AnthonyBarbier avatar AnthonyBarbier commented on May 5, 2024

NESoftMaxLayer is in the list of functions which haven't been ported to use the new accurate padding yet, therefore it falls back onto the overly conservative auto_padding which is why the size ends up being so big.
We're in the process of finishing porting the functions to use the new accurate padding method.
We'll release an update as soon as it's ready.

from computelibrary.

SCUTE-ZZ avatar SCUTE-ZZ commented on May 5, 2024

Thanks I have read the auto_padding.
now I change my code as

Tensor in,out;
in.allocator()->init(TensorInfo(10,1,Format::F32));
out.allocator()->init(*in.info());

NESoftmaxLayer softmax;
softmax.configure(&in,&out);


in.allocator()->allocate();
out.allocator()->allocate();

float in_data[10];
for(int i=0;i<10;i++) in_data[i]=i;

std::copy_n(in_data, 10, 
in.buffer()+in.info()->offset_element_in_bytes(Coordinates(0, 0)));

softmax.run();

float out_data[10];      
std::copy_n(out.buffer()+out.info()->offset_element_in_bytes(Coordinates(0, 0)), 
4*10, out_data);
for(int i=0;i<10;i++) printf("%f ",out_data[i]);
puts("");

but the output was
0.000000 0.000000 0.000000 128.000000 0.000000 0.000000 0.000000 128.000000 0.000000 0.000000

what's wrong for me?

from computelibrary.

GeorgeARM avatar GeorgeARM commented on May 5, 2024

Hello @SCUTE-ZZ,

Can you cast your in pointer to float * when you copy the data to the input tensor (std::copy works differently than mempy)?

std::copy_n(in_data, 10, reinterpret_cast<float*>(in.buffer() + in.info()->offset_element_in_bytes(arm_compute::Coordinates(0, 0))));

from computelibrary.

SCUTE-ZZ avatar SCUTE-ZZ commented on May 5, 2024

Hello @GeorgeARM
now I have use mempy instead of std::copy

Tensor in,out;
in.allocator()->init(TensorInfo(10,1,Format::F32));
out.allocator()->init(*in.info());

NESoftmaxLayer softmax;
softmax.configure(&in,&out);

in.allocator()->allocate();
out.allocator()->allocate();

float in_data[10];
for(int i=0;i<10;i++) in_data[i]=i;
memcpy(
in.buffer()+in.info()->offset_element_in_bytes(Coordinates(0, 0)),
in_data,
10*sizeof(float));

softmax.run();

float out_data[10];
memcpy(
out_data,
out.buffer()+out.info()->offset_element_in_bytes(Coordinates(0, 0)),
10*sizeof(float));

for(int i=0;i<10;i++)
       printf("%f ",out_data[i]);
puts("");

but the output was
-0.000000 -0.000000 -0.000000 -0.000000 -0.000000 -0.000000 -0.000000 -0.000000 -0.000000 -0.000000

from computelibrary.

GeorgeARM avatar GeorgeARM commented on May 5, 2024

@SCUTE-ZZ so it seems they were two problems:
a) you were copying wrong with copy_n which you addressed in the patch above
b) it seems that softmax might fail if your output is not a multiple of 4, we did notice this recently (and is fixed internally) as we added more boards in our testing farm. It seems that an exponent is raised to a really high negative value causing the sequence of calculating this exponent to return -inf breaking the sum part of the softmax equation [exp(x - max(x)) / sum(exp(x - max(x)))], that's why you get -0. We didn't notice this as the boards we were initially testing on didn't have such behavior.

In other words, this will be fixed in the next maintenance release in the following days.

Thanks

from computelibrary.

SCUTE-ZZ avatar SCUTE-ZZ commented on May 5, 2024

@GeorgeARM
I change size 10 to 16 the output was true.
Thanks

from computelibrary.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.