LBANN  0.103.0
LivermoreBigArtificialNeuralNetworkToolkit
dump_minibatch_sample_indices.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.
25 //
26 // dump_minibatch_sample_indices .hpp .cpp - Callbacks
27 // to dump the list of indices per minibatch
29 
30 #ifndef LBANN_CALLBACKS_CALLBACK_DUMP_MINIBATCH_SAMPLE_INDICES_HPP_INCLUDED
31 #define LBANN_CALLBACKS_CALLBACK_DUMP_MINIBATCH_SAMPLE_INDICES_HPP_INCLUDED
32 
33 #include <utility>
34 
36 
37 namespace lbann {
38 namespace callback {
39 
48 {
49 public:
52 
57  dump_minibatch_sample_indices(std::string basename, int batch_interval = 1)
58  : callback_base(batch_interval), m_basename(std::move(basename))
59  {}
62  operator=(const dump_minibatch_sample_indices&) = default;
64  {
65  return new dump_minibatch_sample_indices(*this);
66  }
67  void on_forward_prop_end(model* m, Layer* l) override;
68  void on_evaluate_forward_prop_end(model* m, Layer* l) override;
69 
70  void dump_to_file(model* m, Layer* l, int64_t step);
71 
72  std::string name() const override { return "dump minibatch sample indices"; }
73 
75 
78  template <class Archive>
79  void serialize(Archive& ar);
80 
82 
83 private:
85  void write_specific_proto(lbann_data::Callback& proto) const final;
86 
87  friend class cereal::access;
89 
91  std::string m_basename;
92 };
93 
94 // Builder function
95 std::unique_ptr<callback_base>
96 build_dump_mb_indices_callback_from_pbuf(const google::protobuf::Message&,
97  std::shared_ptr<lbann_summary> const&);
98 
99 } // namespace callback
100 } // namespace lbann
101 
102 #endif // LBANN_CALLBACKS_CALLBACK_DUMP_MINIBATCH_SAMPLE_INDICES_HPP_INCLUDED
virtual void on_evaluate_forward_prop_end(model *m)
Called when a model ends forward propagation for evaluation (validation / testing).
Definition: callback.hpp:183
dump_minibatch_sample_indices(std::string basename, int batch_interval=1)
dump_minibatch_sample_indices * copy() const override
Neural network tensor operation.
Definition: layer.hpp:285
void write_specific_proto(lbann_data::Callback &proto) const final
dump_minibatch_sample_indices & operator=(const dump_minibatch_sample_indices &)=default
std::unique_ptr< callback_base > build_dump_mb_indices_callback_from_pbuf(const google::protobuf::Message &, std::shared_ptr< lbann_summary > const &)
Base class for callbacks during training/testing.
Definition: callback.hpp:76
Abstract base class for neural network models.
Definition: model.hpp:83
Dump sample indices for each minibatch to files.
virtual void on_forward_prop_end(model *m)
Called when a model ends forward propagation.
Definition: callback.hpp:144
void on_evaluate_forward_prop_end(model *m, Layer *l) override
Called when a layer ends forward propagation for evaluation (validation / testing).
void dump_to_file(model *m, Layer *l, int64_t step)
std::string name() const override
Return this callback&#39;s name.
void on_forward_prop_end(model *m, Layer *l) override
Called when a layer ends forward propagation.
void serialize(Archive &ar)
Store state to archive for checkpoint and restart.