22 #ifndef __LOSS_SOFTMAX_CROSS_LAYER_FORWARD_H__
23 #define __LOSS_SOFTMAX_CROSS_LAYER_FORWARD_H__
25 #include "algorithms/algorithm.h"
26 #include "services/daal_defines.h"
27 #include "algorithms/neural_networks/layers/layer.h"
28 #include "algorithms/neural_networks/layers/loss/loss_layer_forward.h"
29 #include "algorithms/neural_networks/layers/loss/softmax_cross_layer_types.h"
30 #include "algorithms/neural_networks/layers/loss/softmax_cross_layer_forward_types.h"
31 #include "algorithms/neural_networks/layers/softmax/softmax_layer_forward.h"
37 namespace neural_networks
43 namespace softmax_cross
64 template<
typename algorithmFPType, Method method, CpuType cpu>
65 class DAAL_EXPORT BatchContainer :
public layers::forward::LayerContainerIfaceImpl
73 BatchContainer(daal::services::Environment::env *daalEnv);
81 services::Status compute() DAAL_C11_OVERRIDE;
102 template<
typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
103 class Batch :
public loss::forward::Batch
106 typedef loss::forward::Batch super;
108 typedef algorithms::neural_networks::layers::loss::softmax_cross::forward::Input InputType;
109 typedef algorithms::neural_networks::layers::loss::softmax_cross::Parameter ParameterType;
110 typedef algorithms::neural_networks::layers::loss::softmax_cross::forward::Result ResultType;
112 ParameterType ¶meter;
116 Batch() : parameter(_defaultParameter)
126 Batch(ParameterType& parameter) : parameter(parameter), _defaultParameter(parameter)
137 Batch(
const Batch<algorithmFPType, method> &other) : super(other),
138 _defaultParameter(other.parameter), parameter(_defaultParameter), input(other.input)
147 virtual int getMethod() const DAAL_C11_OVERRIDE {
return(
int) method; }
153 virtual InputType *getLayerInput() DAAL_C11_OVERRIDE {
return &input; }
159 virtual ParameterType *getLayerParameter() DAAL_C11_OVERRIDE {
return ¶meter; };
165 layers::forward::ResultPtr getLayerResult() DAAL_C11_OVERRIDE
174 ResultPtr getResult()
185 services::Status setResult(
const ResultPtr& result)
187 DAAL_CHECK(result, services::ErrorNullResult)
189 _res = _result.get();
190 return services::Status();
199 services::SharedPtr<Batch<algorithmFPType, method> > clone()
const
201 return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
209 virtual services::Status allocateResult() DAAL_C11_OVERRIDE
211 services::Status s = this->_result->template allocate<algorithmFPType>(&(this->input), ¶meter, (
int) method);
212 this->_res = this->_result.get();
220 virtual layers::forward::LayerIfacePtr getLayerForPrediction() const DAAL_C11_OVERRIDE
222 return layers::forward::LayerIfacePtr(
223 new layers::softmax::forward::Batch<algorithmFPType>());
227 virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
229 return new Batch<algorithmFPType, method>(*this);
234 Analysis<batch>::_ac =
new __DAAL_ALGORITHM_LAYER_CONTAINER(BatchContainer, algorithmFPType, method)(&_env);
237 _result.reset(
new ResultType());
242 ParameterType _defaultParameter;
246 using interface1::BatchContainer;
247 using interface1::Batch;
daal::algorithms::neural_networks::layers::loss::softmax_cross::forward::interface1::Batch::getResult
ResultPtr getResult()
Definition: softmax_cross_layer_forward.h:174
daal
Definition: algorithm_base_common.h:31
daal::algorithms::neural_networks::layers::loss::softmax_cross::forward::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: softmax_cross_layer_forward.h:137
daal::algorithms::neural_networks::layers::loss::softmax_cross::forward::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: softmax_cross_layer_forward.h:147
daal::algorithms::neural_networks::layers::loss::softmax_cross::forward::interface1::Batch::Batch
Batch()
Definition: softmax_cross_layer_forward.h:116
daal::algorithms::neural_networks::layers::loss::softmax_cross::forward::interface1::Batch::input
InputType input
Definition: softmax_cross_layer_forward.h:113
daal::algorithms::neural_networks::layers::loss::softmax_cross::forward::interface1::Batch::parameter
ParameterType & parameter
Definition: softmax_cross_layer_forward.h:112
daal::algorithms::neural_networks::layers::loss::softmax_cross::forward::interface1::Batch::getLayerInput
virtual InputType * getLayerInput() DAAL_C11_OVERRIDE
Definition: softmax_cross_layer_forward.h:153
daal::algorithms::neural_networks::layers::loss::softmax_cross::forward::interface1::Batch::getLayerForPrediction
virtual layers::forward::LayerIfacePtr getLayerForPrediction() const DAAL_C11_OVERRIDE
Definition: softmax_cross_layer_forward.h:220
daal::algorithms::neural_networks::layers::loss::softmax_cross::forward::interface1::BatchContainer
Provides methods to run implementations of the of the forward softmax cross-entropy layer This class ...
Definition: softmax_cross_layer_forward.h:65
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:68
daal::algorithms::neural_networks::layers::loss::softmax_cross::forward::interface1::Batch::getLayerResult
layers::forward::ResultPtr getLayerResult() DAAL_C11_OVERRIDE
Definition: softmax_cross_layer_forward.h:165
daal::algorithms::neural_networks::layers::loss::softmax_cross::forward::interface1::Batch::Batch
Batch(ParameterType ¶meter)
Definition: softmax_cross_layer_forward.h:126
daal::algorithms::neural_networks::layers::loss::softmax_cross::forward::interface1::Batch
Provides methods for the forward softmax cross layer in the batch processing mode.
Definition: softmax_cross_layer_forward.h:103
daal::algorithms::neural_networks::layers::loss::softmax_cross::forward::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: softmax_cross_layer_forward.h:199
daal::algorithms::neural_networks::layers::loss::softmax_cross::forward::interface1::Batch::allocateResult
virtual services::Status allocateResult() DAAL_C11_OVERRIDE
Definition: softmax_cross_layer_forward.h:209
daal::services::ErrorNullResult
Definition: error_indexes.h:96
daal::algorithms::neural_networks::layers::loss::softmax_cross::forward::interface1::Batch::getLayerParameter
virtual ParameterType * getLayerParameter() DAAL_C11_OVERRIDE
Definition: softmax_cross_layer_forward.h:159
daal::algorithms::neural_networks::layers::loss::softmax_cross::forward::interface1::Batch::setResult
services::Status setResult(const ResultPtr &result)
Definition: softmax_cross_layer_forward.h:185