Beatmup
|
#include <softmax.h>
Public Member Functions | |
Softmax (const std::string &name="Softmax") | |
Creates a softmax layer. More... | |
int | getInputCount () const |
Returns number of operation inputs. More... | |
int | getOutputCount () const |
Returns number of operation outputs. More... | |
bool | acceptsStorageInput (int index=0) const |
Returns true if the operation can take a Storage::View at a specific input. More... | |
bool | acceptsVectorInput (int index=0) const |
Returns true if the operation can take a GL::Vector at a specific input. More... | |
void | setInput (Storage::View &&view, int index=0) |
void | setInput (GL::Vector &vector, int index=0) |
std::map< std::string, std::string > | serialize () const |
Returns a serialized representation of th operation;. More... | |
void | disconnect () |
Assigns empty inputs and outputs. More... | |
const std::vector< float > & | getProbabilities () const |
Public Member Functions inherited from Beatmup::NNets::CpuOperation | |
bool | usesGpu () const |
Returns true if the operation is run on GPU. More... | |
Public Member Functions inherited from Beatmup::NNets::AbstractOperation | |
virtual | ~AbstractOperation () |
virtual bool | acceptsTextureInput (int index=0) const |
Returns true if the operation can take a GL::TextureHandler at a specific input. More... | |
virtual bool | acceptsStorageOutput (int index=0) const |
Returns true if the operation can take a Storage::View at a specific output. More... | |
virtual bool | acceptsVectorOutput (int index=0) const |
Returns true if the operation can take a GL::Vector at a specific output. More... | |
virtual bool | acceptsTextureOutput (int index=0) const |
Returns true if the operation can take a GL::TextureHandler at a specific output. More... | |
virtual Size | getOutputSize (int outputIndex=0) const |
Returns full size of a specific operation output. More... | |
virtual Storage::View | getOutput (int index=0) |
Returns a storage view bound to a specific operation output. More... | |
virtual void | getOutput (GL::Vector *&vector, int index=0) |
Returns a GL::Vector bound to a specific operation output. More... | |
virtual void | getOutput (GL::TextureHandler *&vector, int index=0) |
Returns a GL::TextureHandler bound to a specific operation output. More... | |
virtual void | setOutput (Storage::View &&storage, int index=0) |
virtual void | setOutput (GL::Vector &vector, int index=0) |
virtual void | setInput (GL::TextureHandler &image, int index=0) |
virtual void | setOutput (GL::TextureHandler &image, int index=0) |
virtual unsigned long | countMultiplyAdds () const |
Counts (approximate) number of multiply-adds used by this operation. More... | |
virtual unsigned long | countTexelFetches () const |
Counts (approximate) number of texels fetches. More... | |
std::string | getName () const |
Static Public Member Functions | |
static bool | initDeserializer () |
Sets up deserialization of the operation. More... | |
Private Member Functions | |
int | getAmountOfWork () const |
Returns amount of work in arbitrary units to be splitted among threads. More... | |
void | beforeExecute (GraphicPipeline &gpu, const int threadCount) |
Called right before the operation is executed. More... | |
void | execute (const int sliceStart, const int sliceStop, const int threadIdx, const int threadCount) |
Executes the operation body within a specific CPU thread. More... | |
void | afterExecute (const int threadCount) |
Called right after the operation is executed. More... | |
Private Attributes | |
std::vector< float > | output |
std::vector< float > | partialSums |
Storage::View | inputView |
GL::Vector * | inputVector |
Additional Inherited Members | |
Protected Member Functions inherited from Beatmup::NNets::CpuOperation | |
CpuOperation (const std::string &name) | |
void | prepare (GraphicPipeline &gpu, ChunkCollection &data, GL::ProgramBank &bank) |
Compiles GLSL shaders. More... | |
void | getSampledChannels (int index, int &min, int &max) const |
Retrieves range of input features channels sampled at the same time for a specific input. More... | |
void | execute (TaskThread &thread, GraphicPipeline &gpu) |
Executes the operation. More... | |
void | execute (TaskThread &thread) |
Executes the operation within a specific CPU thread. More... | |
Protected Member Functions inherited from Beatmup::NNets::AbstractOperation | |
AbstractOperation (const std::string &name) | |
virtual int | getInputPadding (int index=0) const |
Retrieves minimum required size of zero padding for a given input. More... | |
Softmax layer.
It does not have output, but acts as a sink. The resulting probabilities are returned by getProbabilities(). This operation is executed on CPU.
Softmax::Softmax | ( | const std::string & | name = "Softmax" | ) |
Creates a softmax layer.
[in] | name | Operation name |
Definition at line 26 of file softmax.cpp.
|
privatevirtual |
Returns amount of work in arbitrary units to be splitted among threads.
Implements Beatmup::NNets::CpuOperation.
Definition at line 29 of file softmax.cpp.
|
privatevirtual |
Called right before the operation is executed.
Reimplemented from Beatmup::NNets::CpuOperation.
Definition at line 34 of file softmax.cpp.
|
privatevirtual |
Executes the operation body within a specific CPU thread.
The threads can process different slices according to a given amount of work (see getAmountOfWork()).
[in] | sliceStart | Current slice starting point (included in the slice) |
[in] | sliceStop | Current slice end point (excluded from the slice) |
[in] | threadIdx | Zero-based calling thread number |
[in] | threadCount | Total number of threads executing the operation |
Implements Beatmup::NNets::CpuOperation.
Definition at line 48 of file softmax.cpp.
|
privatevirtual |
Called right after the operation is executed.
Reimplemented from Beatmup::NNets::CpuOperation.
Definition at line 57 of file softmax.cpp.
|
inlinevirtual |
Returns number of operation inputs.
Inputs are then indexed from zero to the returned value minus one inclusive.
Reimplemented from Beatmup::NNets::AbstractOperation.
|
inlinevirtual |
Returns number of operation outputs.
Outputs are then indexed from zero to the returned value minus one inclusive.
Reimplemented from Beatmup::NNets::AbstractOperation.
|
inlinevirtual |
Returns true
if the operation can take a Storage::View at a specific input.
Neural network operations may accept different kinds of data containers on inputs and outputs, namely Storage::View, GL::Vector and textures. This function is used to check whether a given operation accepts a storage view on input.
[in] | index | The input index. Expected to fall in the valid range, i.e. from zero to getInputCount() - 1 inclusive. |
Reimplemented from Beatmup::NNets::AbstractOperation.
Definition at line 54 of file softmax.h.
|
inlinevirtual |
Returns true
if the operation can take a GL::Vector at a specific input.
Neural network operations may accept different kinds of data containers on inputs and outputs, namely Storage::View, GL::Vector and textures. This function is used to check whether a given operation accepts a vector on input.
[in] | index | The input index. Expected to fall in the valid range, i.e. from zero to getInputCount() - 1 inclusive. |
Reimplemented from Beatmup::NNets::AbstractOperation.
Definition at line 55 of file softmax.h.
|
virtual |
Reimplemented from Beatmup::NNets::AbstractOperation.
Definition at line 70 of file softmax.cpp.
|
virtual |
|
virtual |
Returns a serialized representation of th operation;.
Implements Beatmup::NNets::AbstractOperation.
Definition at line 106 of file softmax.cpp.
|
virtual |
Assigns empty inputs and outputs.
Implements Beatmup::NNets::AbstractOperation.
Definition at line 114 of file softmax.cpp.
|
inline |
|
static |
Sets up deserialization of the operation.
|
private |
|
private |
|
private |