google-research

Форк
0
/
random_controller.py 
54 строки · 1.5 Кб
1
# coding=utf-8
2
# Copyright 2024 The Google Research Authors.
3
#
4
# Licensed under the Apache License, Version 2.0 (the "License");
5
# you may not use this file except in compliance with the License.
6
# You may obtain a copy of the License at
7
#
8
#     http://www.apache.org/licenses/LICENSE-2.0
9
#
10
# Unless required by applicable law or agreed to in writing, software
11
# distributed under the License is distributed on an "AS IS" BASIS,
12
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
# See the License for the specific language governing permissions and
14
# limitations under the License.
15

16
"""Random Controller that proposes random topologies."""
17

18
import pyglove as pg
19
from es_enas.controllers import base_controller
20

21

22
class RandomController(base_controller.BaseController):
23
  """Random Search Controller."""
24

25
  def __init__(self, dna_spec, batch_size,
26
               **kwargs):
27
    """Initialization. See base class for more details."""
28
    super().__init__(dna_spec, batch_size)
29
    del kwargs
30

31
  def propose_dna(self):
32
    """Proposes a topology dna using stored template.
33

34
    Args: None.
35

36
    Returns:
37
      dna: A proposed dna.
38
    """
39
    return pg.random_dna(self._dna_spec)
40

41
  def collect_rewards_and_train(self, reward_vector, dna_list):
42
    """Collects rewards and sends them to the replay buffer.
43

44
    Args:
45
      reward_vector: list of reward floats.
46
      dna_list: list of dna's from the proposal function.
47

48
    Returns:
49
      None.
50
    """
51

52
    del reward_vector
53
    del dna_list
54
    pass
55

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.