LBANN  0.103.0
LivermoreBigArtificialNeuralNetworkToolkit
truncation_selection_exchange.hpp
Go to the documentation of this file.
1 // Copyright (c) 2014-2023, Lawrence Livermore National Security, LLC.
3 // Produced at the Lawrence Livermore National Laboratory.
4 // Written by the LBANN Research Team (B. Van Essen, et al.) listed in
5 // the CONTRIBUTORS file. <lbann-dev@llnl.gov>
6 //
7 // LLNL-CODE-697807.
8 // All rights reserved.
9 //
10 // This file is part of LBANN: Livermore Big Artificial Neural Network
11 // Toolkit. For details, see http://software.llnl.gov/LBANN or
12 // https://github.com/LLNL/LBANN.
13 //
14 // Licensed under the Apache License, Version 2.0 (the "Licensee"); you
15 // may not use this file except in compliance with the License. You may
16 // obtain a copy of the License at:
17 //
18 // http://www.apache.org/licenses/LICENSE-2.0
19 //
20 // Unless required by applicable law or agreed to in writing, software
21 // distributed under the License is distributed on an "AS IS" BASIS,
22 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
23 // implied. See the License for the specific language governing
24 // permissions and limitations under the license.
26 #ifndef LBANN_EXECUTION_ALGORITHMS_LTFB_TRUNCATION_SELECTION_EXCHANGE_HPP_INCLUDED
27 #define LBANN_EXECUTION_ALGORITHMS_LTFB_TRUNCATION_SELECTION_EXCHANGE_HPP_INCLUDED
28 
30 
31 #include <google/protobuf/message.h>
32 
33 #include <cstddef>
34 #include <memory>
35 #include <string>
36 #include <unordered_map>
37 
38 namespace lbann {
39 namespace ltfb {
40 
51  : public Cloneable<TruncationSelectionExchange, MetaLearningStrategy>
52 {
53 public:
54  enum class metric_strategy
55  {
58  }; // enum class metric_strategy
59 
60 public:
62 
72  TruncationSelectionExchange(std::string metric_name,
73  metric_strategy winner_strategy,
74  int truncation_k);
75 
84  std::unordered_map<std::string, metric_strategy> metrics,
85  int truncation_k);
86 
87  ~TruncationSelectionExchange() = default;
90 
100  void select_next(model& m,
102  data_coordinator& dc) const final;
103 
104 private:
107  LTFBExecutionContext& ctxt,
108  data_coordinator& dc) const;
109 
110 private:
118  std::unordered_map<std::string, metric_strategy> m_metrics;
119 
120  /* partitions ranking of trainers to top (winners) and below (loosers)
121  */
123 
124 }; // class TruncationSelectionExchange
125 
126 } // namespace ltfb
127 
129 
132 template <>
133 std::unique_ptr<ltfb::TruncationSelectionExchange>
134 make(google::protobuf::Message const&);
135 
137 
138 } // namespace lbann
139 #endif // LBANN_EXECUTION_ALGORITHMS_LTFB_TRUNCATION_SELECTION_EXCHANGE_HPP_INCLUDED
Inject polymorphic clone functions into hierarchies.
Definition: cloneable.hpp:94
std::unordered_map< std::string, metric_strategy > m_metrics
The list of metric/strategy pairs.
TruncationSelectionExchange(std::string metric_name, metric_strategy winner_strategy, int truncation_k)
Constructor.
EvalType evaluate_model(model &m, LTFBExecutionContext &ctxt, data_coordinator &dc) const
Get the value of the given metric from the model.
Abstract base class for neural network models.
Definition: model.hpp:83
std::unique_ptr< ltfb::RandomPairwiseExchange > make(google::protobuf::Message const &)
Concrete builder for RandomPairwiseExchange.
void select_next(model &m, ltfb::LTFBExecutionContext &ctxt, data_coordinator &dc) const final
Engage in a ranked tournament with a population of trainers.
double EvalType
Definition: base.hpp:189