49 #ifndef __NEURAL_NETWORKS_TRAINING_DISTRIBUTED_H__
50 #define __NEURAL_NETWORKS_TRAINING_DISTRIBUTED_H__
52 #include "algorithms/algorithm.h"
54 #include "services/daal_defines.h"
55 #include "algorithms/neural_networks/neural_networks_types.h"
56 #include "algorithms/neural_networks/neural_networks_training_types.h"
57 #include "algorithms/neural_networks/neural_networks_training_model.h"
58 #include "algorithms/neural_networks/layers/layer.h"
67 namespace neural_networks
83 template<ComputeStep step,
typename algorithmFPType, Method method, CpuType cpu>
84 class DAAL_EXPORT DistributedContainer
91 template<
typename algorithmFPType, Method method, CpuType cpu>
92 class DAAL_EXPORT DistributedContainer<step1Local, algorithmFPType, method, cpu> :
public TrainingContainerIface<distributed>
100 DistributedContainer(daal::services::Environment::env *daalEnv);
102 ~DistributedContainer();
106 services::Status compute() DAAL_C11_OVERRIDE;
107 services::Status setupCompute() DAAL_C11_OVERRIDE;
108 services::Status resetCompute() DAAL_C11_OVERRIDE;
113 services::Status finalizeCompute() DAAL_C11_OVERRIDE;
120 template<
typename algorithmFPType, Method method, CpuType cpu>
121 class DAAL_EXPORT DistributedContainer<step2Master, algorithmFPType, method, cpu> :
public TrainingContainerIface<distributed>
129 DistributedContainer(daal::services::Environment::env *daalEnv);
131 ~DistributedContainer();
135 services::Status compute() DAAL_C11_OVERRIDE;
136 services::Status setupCompute() DAAL_C11_OVERRIDE;
137 services::Status resetCompute() DAAL_C11_OVERRIDE;
142 services::Status finalizeCompute() DAAL_C11_OVERRIDE;
163 template<ComputeStep step,
typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
164 class DAAL_EXPORT Distributed
183 template<
typename algorithmFPType, Method method>
184 class DAAL_EXPORT Distributed<step1Local, algorithmFPType, method> :
public Training<distributed>
187 DistributedInput<step1Local> input;
201 Distributed(
const Distributed<step1Local, algorithmFPType, method> &other) : parameter(other.parameter), input(other.input)
206 virtual ~Distributed() {}
214 services::Status setPartialResult(
const PartialResultPtr& partialResult)
216 _partialResult = partialResult;
217 _pres = _partialResult.get();
218 return services::Status();
225 PartialResultPtr getPartialResult() {
return _partialResult; }
231 ResultPtr getResult()
242 services::Status setResult(
const ResultPtr& res)
244 DAAL_CHECK(res, services::ErrorNullResult)
246 _res = _result.get();
247 return services::Status();
255 services::SharedPtr<Distributed<step1Local, algorithmFPType, method> > clone()
const
257 return services::SharedPtr<Distributed<step1Local, algorithmFPType, method> >(cloneImpl());
264 virtual int getMethod() const DAAL_C11_OVERRIDE {
return(
int) method; }
269 _ac =
new __DAAL_ALGORITHM_CONTAINER(distributed, DistributedContainer, step1Local, algorithmFPType, method)(&_env);
272 _partialResult.reset(
new PartialResult());
273 _result.reset(
new Result());
276 virtual Distributed<step1Local, algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
278 return new Distributed<step1Local, algorithmFPType, method>(*this);
281 virtual services::Status allocateResult() DAAL_C11_OVERRIDE
283 services::Status s = _result->allocate<algorithmFPType>(&input, ¶meter, (int) method);
284 _res = _result.get();
288 services::Status allocatePartialResult() DAAL_C11_OVERRIDE
290 services::Status s = _partialResult->allocate<algorithmFPType>(&input, ¶meter, method);
291 _pres = _partialResult.get();
295 virtual services::Status initializePartialResult() DAAL_C11_OVERRIDE
297 _pres = _partialResult.get();
298 return services::Status();
301 PartialResultPtr _partialResult;
320 template<
typename algorithmFPType, Method method>
321 class DAAL_EXPORT Distributed<step2Master, algorithmFPType, method> :
public Training<distributed>
324 DistributedInput<step2Master> input;
327 Distributed(
const services::SharedPtr<optimization_solver::iterative_solver::Batch >& optimizationSolver_) : parameter(optimizationSolver_)
337 Distributed(
const Distributed<step2Master, algorithmFPType, method> &other) : parameter(other.parameter), input(other.input)
342 virtual ~Distributed() {}
351 services::Status initialize(
const services::Collection<size_t> &dataSize,
const training::Topology &topology)
353 ResultPtr result = getResult();
354 if (!result || !result->get(neural_networks::training::model))
356 return services::Status(services::ErrorNullModel);
358 result->get(neural_networks::training::model)->initialize<algorithmFPType>(dataSize, topology, parameter);
359 return services::Status();
368 services::Status setPartialResult(
const DistributedPartialResultPtr& partialResult)
370 _partialResult = partialResult;
371 _pres = _partialResult.get();
372 return services::Status();
379 DistributedPartialResultPtr getPartialResult() {
return _partialResult; }
385 ResultPtr getResult()
387 return _partialResult->get(resultFromMaster);
395 services::SharedPtr<Distributed<step2Master, algorithmFPType, method> > clone()
const
397 return services::SharedPtr<Distributed<step2Master, algorithmFPType, method> >(cloneImpl());
404 virtual int getMethod() const DAAL_C11_OVERRIDE {
return(
int) method; }
409 _ac =
new __DAAL_ALGORITHM_CONTAINER(distributed, DistributedContainer, step2Master, algorithmFPType, method)(&_env);
412 _partialResult = DistributedPartialResultPtr(
new DistributedPartialResult());
415 virtual Distributed<step2Master, algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
417 return new Distributed<step2Master, algorithmFPType, method>(*this);
420 virtual services::Status allocateResult() DAAL_C11_OVERRIDE
422 return services::Status();
425 services::Status allocatePartialResult() DAAL_C11_OVERRIDE
427 services::Status s = _partialResult->allocate<algorithmFPType>(&input, ¶meter, method);
428 _pres = _partialResult.get();
432 virtual services::Status initializePartialResult() DAAL_C11_OVERRIDE
434 _pres = _partialResult.get();
435 return services::Status();
438 DistributedPartialResultPtr _partialResult;
442 using interface1::Distributed;
443 using interface1::DistributedContainer;
daal::algorithms::neural_networks::training::interface1::Distributed< step1Local, algorithmFPType, method >::parameter
Parameter parameter
Definition: neural_networks_training_distributed.h:188
daal::algorithms::neural_networks::training::interface1::Distributed< step1Local, algorithmFPType, method >::setResult
services::Status setResult(const ResultPtr &res)
Definition: neural_networks_training_distributed.h:242
daal
Definition: algorithm_base_common.h:57
daal::algorithms::neural_networks::training::interface1::Distributed< step2Master, algorithmFPType, method >::Distributed
Distributed(const Distributed< step2Master, algorithmFPType, method > &other)
Definition: neural_networks_training_distributed.h:337
daal::algorithms::neural_networks::training::interface1::Distributed< step1Local, algorithmFPType, method >::Distributed
Distributed()
Definition: neural_networks_training_distributed.h:191
daal::algorithms::neural_networks::training::interface1::Distributed< step2Master, algorithmFPType, method >::initialize
services::Status initialize(const services::Collection< size_t > &dataSize, const training::Topology &topology)
Definition: neural_networks_training_distributed.h:351
daal::algorithms::neural_networks::training::interface1::Distributed< step1Local, algorithmFPType, method >::Distributed
Distributed(const Distributed< step1Local, algorithmFPType, method > &other)
Definition: neural_networks_training_distributed.h:201
daal::algorithms::neural_networks::training::interface1::Distributed< step1Local, algorithmFPType, method >::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: neural_networks_training_distributed.h:264
daal::algorithms::neural_networks::training::interface1::Distributed< step2Master, algorithmFPType, method >::clone
services::SharedPtr< Distributed< step2Master, algorithmFPType, method > > clone() const
Definition: neural_networks_training_distributed.h:395
daal::algorithms::kmeans::init::interface1::Distributed
class DAAL_EXPORT Distributed
Computes initial clusters for the K-Means algorithm in the distributed processing mode...
Definition: kmeans_init_distributed.h:281
daal::distributed
Definition: daal_defines.h:132
daal::algorithms::neural_networks::training::interface1::DistributedPartialResult
Provides methods to access partial result obtained with the compute() method of the neural network tr...
Definition: neural_networks_training_partial_result.h:165
daal::algorithms::neural_networks::training::interface1::Parameter
Class representing the parameters of neural network.
Definition: neural_networks_training_model.h:85
daal::algorithms::neural_networks::training::interface1::Distributed< step2Master, algorithmFPType, method >::parameter
Parameter parameter
Definition: neural_networks_training_distributed.h:325
daal::algorithms::neural_networks::training::interface1::Result
Provides methods to access result obtained with the compute() method of the neural network training a...
Definition: neural_networks_training_result.h:91
daal::algorithms::neural_networks::training::interface1::Distributed< step2Master, algorithmFPType, method >::setPartialResult
services::Status setPartialResult(const DistributedPartialResultPtr &partialResult)
Definition: neural_networks_training_distributed.h:368
daal::algorithms::neural_networks::training::interface1::Distributed< step1Local, algorithmFPType, method >::clone
services::SharedPtr< Distributed< step1Local, algorithmFPType, method > > clone() const
Definition: neural_networks_training_distributed.h:255
daal::algorithms::neural_networks::training::interface1::Distributed< step1Local, algorithmFPType, method >::input
DistributedInput< step1Local > input
Definition: neural_networks_training_distributed.h:187
daal::algorithms::neural_networks::training::interface1::Distributed< step2Master, algorithmFPType, method >
Provides methods for neural network model-based training in the batch processing mode.
Definition: neural_networks_training_distributed.h:321
daal::services::ErrorNullModel
Definition: error_indexes.h:109
daal::algorithms::neural_networks::training::interface1::Distributed
Provides methods for neural network model-based training in the batch processing mode.
Definition: neural_networks_training_distributed.h:164
daal::algorithms::neural_networks::training::interface1::Distributed< step2Master, algorithmFPType, method >::getResult
ResultPtr getResult()
Definition: neural_networks_training_distributed.h:385
daal::algorithms::neural_networks::training::interface1::Distributed< step1Local, algorithmFPType, method >
Provides methods for neural network model-based training in the batch processing mode.
Definition: neural_networks_training_distributed.h:184
daal::algorithms::kmeans::interface1::DistributedContainer
class DAAL_EXPORT DistributedContainer
Provides methods to run implementations of the K-Means algorithm. This class is associated with the d...
Definition: kmeans_distributed.h:81
daal::step1Local
Definition: daal_defines.h:142
daal::algorithms::neural_networks::training::interface1::PartialResult
Provides methods to access partial result obtained with the compute() method of the neural network tr...
Definition: neural_networks_training_partial_result.h:107
daal::algorithms::neural_networks::training::interface1::Distributed< step1Local, algorithmFPType, method >::getResult
ResultPtr getResult()
Definition: neural_networks_training_distributed.h:231
daal::algorithms::neural_networks::training::interface1::Distributed< step1Local, algorithmFPType, method >::getPartialResult
PartialResultPtr getPartialResult()
Definition: neural_networks_training_distributed.h:225
daal::step2Master
Definition: daal_defines.h:143
daal::algorithms::neural_networks::training::interface1::Distributed< step2Master, algorithmFPType, method >::getPartialResult
DistributedPartialResultPtr getPartialResult()
Definition: neural_networks_training_distributed.h:379
daal::algorithms::neural_networks::training::model
Definition: neural_networks_training_result.h:78
daal::algorithms::neural_networks::training::interface1::Distributed< step2Master, algorithmFPType, method >::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: neural_networks_training_distributed.h:404
daal::services::ErrorNullResult
Definition: error_indexes.h:122
daal::algorithms::neural_networks::training::interface1::Distributed< step1Local, algorithmFPType, method >::setPartialResult
services::Status setPartialResult(const PartialResultPtr &partialResult)
Definition: neural_networks_training_distributed.h:214
daal::algorithms::neural_networks::training::interface1::DistributedContainer
Class containing methods to train neural network model in the distributed processing mode using algor...
Definition: neural_networks_training_distributed.h:84
daal::algorithms::TrainingContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the model...
Definition: training.h:76
daal::algorithms::Training
Provides methods to train models that depend on the data provided. For example, these methods enable ...
Definition: training.h:86
daal::algorithms::neural_networks::training::interface1::Distributed< step2Master, algorithmFPType, method >::input
DistributedInput< step2Master > input
Definition: neural_networks_training_distributed.h:324