training_algorithm.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright 2018 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef MEDIA_LEARNING_IMPL_TRAINING_ALGORITHM_H_
  5. #define MEDIA_LEARNING_IMPL_TRAINING_ALGORITHM_H_
  6. #include <memory>
  7. #include "base/callback.h"
  8. #include "media/learning/common/labelled_example.h"
  9. #include "media/learning/impl/model.h"
  10. namespace media {
  11. namespace learning {
  12. // Returns a trained model.
  13. using TrainedModelCB = base::OnceCallback<void(std::unique_ptr<Model>)>;
  14. // Base class for training algorithms.
  15. class TrainingAlgorithm {
  16. public:
  17. TrainingAlgorithm() = default;
  18. TrainingAlgorithm(const TrainingAlgorithm&) = delete;
  19. TrainingAlgorithm& operator=(const TrainingAlgorithm&) = delete;
  20. virtual ~TrainingAlgorithm() = default;
  21. virtual void Train(const LearningTask& task,
  22. const TrainingData& training_data,
  23. TrainedModelCB model_cb) = 0;
  24. };
  25. } // namespace learning
  26. } // namespace media
  27. #endif // MEDIA_LEARNING_IMPL_TRAINING_ALGORITHM_H_