25 #ifndef __NEURAL_NETWORKS_TRAINING_DISTRIBUTED_H__
26 #define __NEURAL_NETWORKS_TRAINING_DISTRIBUTED_H__
28 #include "algorithms/algorithm.h"
30 #include "services/daal_defines.h"
31 #include "algorithms/neural_networks/neural_networks_types.h"
32 #include "algorithms/neural_networks/neural_networks_training_types.h"
33 #include "algorithms/neural_networks/neural_networks_training_model.h"
34 #include "algorithms/neural_networks/layers/layer.h"
43 namespace neural_networks
60 template<ComputeStep step,
typename algorithmFPType, Method method, CpuType cpu>
61 class DistributedContainer
69 template<
typename algorithmFPType, Method method, CpuType cpu>
70 class DistributedContainer<step1Local, algorithmFPType, method, cpu> :
public TrainingContainerIface<distributed>
79 DAAL_DEPRECATED DistributedContainer(daal::services::Environment::env *daalEnv);
83 DAAL_DEPRECATED ~DistributedContainer();
88 DAAL_DEPRECATED services::Status compute() DAAL_C11_OVERRIDE;
92 DAAL_DEPRECATED services::Status setupCompute() DAAL_C11_OVERRIDE;
96 DAAL_DEPRECATED services::Status resetCompute() DAAL_C11_OVERRIDE;
102 DAAL_DEPRECATED services::Status finalizeCompute() DAAL_C11_OVERRIDE;
110 template<
typename algorithmFPType, Method method, CpuType cpu>
111 class DistributedContainer<step2Master, algorithmFPType, method, cpu> :
public TrainingContainerIface<distributed>
120 DAAL_DEPRECATED DistributedContainer(daal::services::Environment::env *daalEnv);
124 DAAL_DEPRECATED ~DistributedContainer();
129 DAAL_DEPRECATED services::Status compute() DAAL_C11_OVERRIDE;
133 DAAL_DEPRECATED services::Status setupCompute() DAAL_C11_OVERRIDE;
137 DAAL_DEPRECATED services::Status resetCompute() DAAL_C11_OVERRIDE;
143 DAAL_DEPRECATED services::Status finalizeCompute() DAAL_C11_OVERRIDE;
166 template<ComputeStep step,
typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
167 class DAAL_EXPORT Distributed
188 template<
typename algorithmFPType, Method method>
189 class DAAL_EXPORT Distributed<step1Local, algorithmFPType, method> :
public Training<distributed>
192 typedef algorithms::neural_networks::training::DistributedInput<step1Local> InputType;
193 typedef algorithms::neural_networks::training::Parameter ParameterType;
194 typedef algorithms::neural_networks::training::Result ResultType;
195 typedef algorithms::neural_networks::training::PartialResult PartialResultType;
197 DistributedInput<step1Local> input;
198 ParameterType parameter;
203 DAAL_DEPRECATED Distributed()
214 Distributed(
const Distributed<step1Local, algorithmFPType, method> &other) : parameter(other.parameter), input(other.input)
222 virtual ~Distributed() {}
231 DAAL_DEPRECATED services::Status setPartialResult(
const PartialResultPtr& partialResult)
233 _partialResult = partialResult;
234 _pres = _partialResult.get();
235 return services::Status();
243 DAAL_DEPRECATED PartialResultPtr getPartialResult() {
return _partialResult; }
250 DAAL_DEPRECATED ResultPtr getResult()
262 DAAL_DEPRECATED services::Status setResult(
const ResultPtr& res)
264 DAAL_CHECK(res, services::ErrorNullResult)
266 _res = _result.get();
267 return services::Status();
276 DAAL_DEPRECATED services::SharedPtr<Distributed<step1Local, algorithmFPType, method> > clone()
const
278 return services::SharedPtr<Distributed<step1Local, algorithmFPType, method> >(cloneImpl());
286 DAAL_DEPRECATED_VIRTUAL
virtual int getMethod() const DAAL_C11_OVERRIDE {
return(
int) method; }
294 _ac =
new __DAAL_ALGORITHM_CONTAINER(distributed, DistributedContainer, step1Local, algorithmFPType, method)(&_env);
297 _partialResult.reset(
new PartialResultType());
298 _result.reset(
new ResultType());
304 DAAL_DEPRECATED_VIRTUAL
virtual Distributed<step1Local, algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
306 return new Distributed<step1Local, algorithmFPType, method>(*this);
312 DAAL_DEPRECATED_VIRTUAL
virtual services::Status allocateResult() DAAL_C11_OVERRIDE
314 services::Status s = _result->allocate<algorithmFPType>(&input, ¶meter, (int) method);
315 _res = _result.get();
322 DAAL_DEPRECATED services::Status allocatePartialResult() DAAL_C11_OVERRIDE
324 services::Status s = _partialResult->allocate<algorithmFPType>(&input, ¶meter, method);
325 _pres = _partialResult.get();
332 DAAL_DEPRECATED_VIRTUAL
virtual services::Status initializePartialResult() DAAL_C11_OVERRIDE
334 _pres = _partialResult.get();
335 return services::Status();
338 PartialResultPtr _partialResult;
359 template<
typename algorithmFPType, Method method>
360 class DAAL_EXPORT Distributed<step2Master, algorithmFPType, method> :
public Training<distributed>
363 typedef algorithms::neural_networks::training::DistributedInput<step2Master> InputType;
364 typedef algorithms::neural_networks::training::Parameter ParameterType;
365 typedef algorithms::neural_networks::training::Result ResultType;
366 typedef algorithms::neural_networks::training::DistributedPartialResult PartialResultType;
368 DistributedInput<step2Master> input;
369 ParameterType parameter;
374 DAAL_DEPRECATED Distributed(
const services::SharedPtr<optimization_solver::iterative_solver::Batch >& optimizationSolver_) : parameter(optimizationSolver_)
385 Distributed(
const Distributed<step2Master, algorithmFPType, method> &other) : parameter(other.parameter), input(other.input)
393 virtual ~Distributed() {}
403 DAAL_DEPRECATED services::Status initialize(
const services::Collection<size_t> &dataSize,
const training::Topology &topology)
405 ResultPtr result = getResult();
406 if (!result || !result->get(neural_networks::training::model))
408 return services::Status(services::ErrorNullModel);
410 result->get(neural_networks::training::model)->initialize<algorithmFPType>(dataSize, topology, parameter);
411 return services::Status();
421 DAAL_DEPRECATED services::Status setPartialResult(
const DistributedPartialResultPtr& partialResult)
423 _partialResult = partialResult;
424 _pres = _partialResult.get();
425 return services::Status();
433 DAAL_DEPRECATED DistributedPartialResultPtr getPartialResult() {
return _partialResult; }
440 ResultPtr getResult()
442 return _partialResult->get(resultFromMaster);
451 DAAL_DEPRECATED services::SharedPtr<Distributed<step2Master, algorithmFPType, method> > clone()
const
453 return services::SharedPtr<Distributed<step2Master, algorithmFPType, method> >(cloneImpl());
461 DAAL_DEPRECATED_VIRTUAL
virtual int getMethod() const DAAL_C11_OVERRIDE {
return(
int) method; }
469 _ac =
new __DAAL_ALGORITHM_CONTAINER(distributed, DistributedContainer, step2Master, algorithmFPType, method)(&_env);
472 _partialResult = DistributedPartialResultPtr(
new PartialResultType());
478 DAAL_DEPRECATED_VIRTUAL
virtual Distributed<step2Master, algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
480 return new Distributed<step2Master, algorithmFPType, method>(*this);
486 DAAL_DEPRECATED_VIRTUAL
virtual services::Status allocateResult() DAAL_C11_OVERRIDE
488 return services::Status();
494 DAAL_DEPRECATED services::Status allocatePartialResult() DAAL_C11_OVERRIDE
496 services::Status s = _partialResult->allocate<algorithmFPType>(&input, ¶meter, method);
497 _pres = _partialResult.get();
504 DAAL_DEPRECATED_VIRTUAL
virtual services::Status initializePartialResult() DAAL_C11_OVERRIDE
506 _pres = _partialResult.get();
507 return services::Status();
510 DistributedPartialResultPtr _partialResult;
514 using interface1::Distributed;
515 using interface1::DistributedContainer;
daal::step1Local
Definition: daal_defines.h:123
daal::algorithms::neural_networks::training::interface1::Distributed< step1Local, algorithmFPType, method >::initialize
void initialize()
Definition: neural_networks_training_distributed.h:292
daal::algorithms::neural_networks::training::interface1::Distributed< step2Master, algorithmFPType, method >::cloneImpl
virtual DAAL_DEPRECATED_VIRTUAL Distributed< step2Master, algorithmFPType, method > * cloneImpl() const DAAL_C11_OVERRIDE
Definition: neural_networks_training_distributed.h:478
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:167
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:189
daal::algorithms::neural_networks::training::interface1::Distributed< step2Master, algorithmFPType, method >::~Distributed
virtual ~Distributed()
Definition: neural_networks_training_distributed.h:393
daal::algorithms::neural_networks::training::interface1::Distributed< step2Master, algorithmFPType, method >::initialize
void initialize()
Definition: neural_networks_training_distributed.h:467
daal::algorithms::neural_networks::training::interface1::Distributed< step2Master, algorithmFPType, method >::input
DistributedInput< step2Master > input
Definition: neural_networks_training_distributed.h:368
daal::algorithms::neural_networks::training::interface1::Distributed< step1Local, algorithmFPType, method >::Distributed
DAAL_DEPRECATED Distributed()
Definition: neural_networks_training_distributed.h:203
daal::step2Master
Definition: daal_defines.h:124
daal::algorithms::neural_networks::training::interface1::Distributed< step2Master, algorithmFPType, method >::getMethod
virtual DAAL_DEPRECATED_VIRTUAL int getMethod() const DAAL_C11_OVERRIDE
Definition: neural_networks_training_distributed.h:461
daal::algorithms::neural_networks::training::interface1::Distributed< step2Master, algorithmFPType, method >::clone
DAAL_DEPRECATED services::SharedPtr< Distributed< step2Master, algorithmFPType, method > > clone() const
Definition: neural_networks_training_distributed.h:451
daal::algorithms::neural_networks::training::interface1::Distributed< step2Master, algorithmFPType, method >::allocateResult
virtual DAAL_DEPRECATED_VIRTUAL services::Status allocateResult() DAAL_C11_OVERRIDE
Definition: neural_networks_training_distributed.h:486
daal::algorithms::neural_networks::training::interface1::Distributed< step2Master, algorithmFPType, method >::parameter
ParameterType parameter
Definition: neural_networks_training_distributed.h:369
daal::algorithms::neural_networks::training::interface1::Distributed< step1Local, algorithmFPType, method >::setResult
DAAL_DEPRECATED services::Status setResult(const ResultPtr &res)
Definition: neural_networks_training_distributed.h:262
daal::services::ErrorNullResult
Definition: error_indexes.h:98
daal::algorithms::neural_networks::training::interface1::Distributed< step2Master, algorithmFPType, method >::initializePartialResult
virtual DAAL_DEPRECATED_VIRTUAL services::Status initializePartialResult() DAAL_C11_OVERRIDE
Definition: neural_networks_training_distributed.h:504
daal::algorithms::neural_networks::training::interface1::Distributed< step1Local, algorithmFPType, method >::clone
DAAL_DEPRECATED services::SharedPtr< Distributed< step1Local, algorithmFPType, method > > clone() const
Definition: neural_networks_training_distributed.h:276
daal::algorithms::neural_networks::training::interface1::DistributedInput< step2Master >
Input objects of the neural network training algorithm.
Definition: neural_networks_training_input.h:255
daal::algorithms::kmeans::init::interface2::Distributed
class DAAL_EXPORT Distributed
Computes initial clusters for K-Means algorithm in the distributed processing mode.
Definition: kmeans_init_distributed.h:277
daal::algorithms::neural_networks::training::interface1::Distributed< step1Local, algorithmFPType, method >::getMethod
virtual DAAL_DEPRECATED_VIRTUAL int getMethod() const DAAL_C11_OVERRIDE
Definition: neural_networks_training_distributed.h:286
daal::algorithms::neural_networks::training::interface1::Distributed< step2Master, algorithmFPType, method >::getPartialResult
DAAL_DEPRECATED DistributedPartialResultPtr getPartialResult()
Definition: neural_networks_training_distributed.h:433
daal::algorithms::neural_networks::training::interface1::Distributed< step2Master, algorithmFPType, method >::allocatePartialResult
DAAL_DEPRECATED services::Status allocatePartialResult() DAAL_C11_OVERRIDE
Definition: neural_networks_training_distributed.h:494
daal::algorithms::neural_networks::training::interface1::Distributed< step2Master, algorithmFPType, method >::Distributed
DAAL_DEPRECATED Distributed(const services::SharedPtr< optimization_solver::iterative_solver::Batch > &optimizationSolver_)
Definition: neural_networks_training_distributed.h:374
daal::algorithms::neural_networks::training::interface1::Distributed< step2Master, algorithmFPType, method >::initialize
DAAL_DEPRECATED services::Status initialize(const services::Collection< size_t > &dataSize, const training::Topology &topology)
Definition: neural_networks_training_distributed.h:403
daal::algorithms::neural_networks::training::interface1::Distributed< step1Local, algorithmFPType, method >::allocateResult
virtual DAAL_DEPRECATED_VIRTUAL services::Status allocateResult() DAAL_C11_OVERRIDE
Definition: neural_networks_training_distributed.h:312
daal::algorithms::neural_networks::training::interface1::Distributed< step1Local, algorithmFPType, method >::parameter
ParameterType parameter
Definition: neural_networks_training_distributed.h:198
daal::algorithms::neural_networks::training::interface1::Distributed< step2Master, algorithmFPType, method >::setPartialResult
DAAL_DEPRECATED services::Status setPartialResult(const DistributedPartialResultPtr &partialResult)
Definition: neural_networks_training_distributed.h:421
daal::algorithms::neural_networks::training::interface1::Distributed< step1Local, algorithmFPType, method >::initializePartialResult
virtual DAAL_DEPRECATED_VIRTUAL services::Status initializePartialResult() DAAL_C11_OVERRIDE
Definition: neural_networks_training_distributed.h:332
daal::services::ErrorNullModel
Definition: error_indexes.h:85
daal::algorithms::Training
Provides methods to train models that depend on the data provided. For example, these methods enable ...
Definition: training.h:62
daal::algorithms::neural_networks::training::interface1::Distributed< step1Local, algorithmFPType, method >::allocatePartialResult
DAAL_DEPRECATED services::Status allocatePartialResult() DAAL_C11_OVERRIDE
Definition: neural_networks_training_distributed.h:322
daal::algorithms::neural_networks::training::interface1::Distributed< step2Master, algorithmFPType, method >::Distributed
Distributed(const Distributed< step2Master, algorithmFPType, method > &other)
Definition: neural_networks_training_distributed.h:385
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:61
daal::algorithms::neural_networks::training::interface1::Distributed< step1Local, algorithmFPType, method >::Distributed
Distributed(const Distributed< step1Local, algorithmFPType, method > &other)
Definition: neural_networks_training_distributed.h:214
daal::algorithms::neural_networks::training::interface1::DistributedInput< step1Local >
Input objects of the neural network training algorithm in the distributed processing mode...
Definition: neural_networks_training_input.h:202
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:360
daal::algorithms::neural_networks::training::interface1::Distributed< step1Local, algorithmFPType, method >::getResult
DAAL_DEPRECATED ResultPtr getResult()
Definition: neural_networks_training_distributed.h:250
daal::algorithms::neural_networks::training::interface1::Distributed< step1Local, algorithmFPType, method >::getPartialResult
DAAL_DEPRECATED PartialResultPtr getPartialResult()
Definition: neural_networks_training_distributed.h:243
daal::algorithms::neural_networks::training::interface1::Distributed< step1Local, algorithmFPType, method >::cloneImpl
virtual DAAL_DEPRECATED_VIRTUAL Distributed< step1Local, algorithmFPType, method > * cloneImpl() const DAAL_C11_OVERRIDE
Definition: neural_networks_training_distributed.h:304
daal::algorithms::neural_networks::training::interface1::Distributed< step2Master, algorithmFPType, method >::getResult
ResultPtr getResult()
Definition: neural_networks_training_distributed.h:440
daal::algorithms::neural_networks::training::interface1::Distributed< step1Local, algorithmFPType, method >::input
DistributedInput< step1Local > input
Definition: neural_networks_training_distributed.h:197
daal::distributed
Definition: daal_defines.h:113
daal::algorithms::neural_networks::training::model
Definition: neural_networks_training_result.h:54
daal::algorithms::neural_networks::training::interface1::Distributed< step1Local, algorithmFPType, method >::setPartialResult
DAAL_DEPRECATED services::Status setPartialResult(const PartialResultPtr &partialResult)
Definition: neural_networks_training_distributed.h:231
daal::algorithms::TrainingContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the model...
Definition: training.h:52
daal::algorithms::neural_networks::training::interface1::Distributed< step1Local, algorithmFPType, method >::~Distributed
virtual ~Distributed()
Definition: neural_networks_training_distributed.h:222