repo stringlengths 1 99 | file stringlengths 13 215 | code stringlengths 12 59.2M | file_length int64 12 59.2M | avg_line_length float64 3.82 1.48M | max_line_length int64 12 2.51M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
ReAgent | ReAgent-master/reagent/training/world_model/mdnrnn_trainer.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import logging
from typing import Optional
import reagent.core.types as rlt
import torch
import torch.nn.functional as F
from reagent.core.parameters import MDNRNNTrainerParameters
from reagent.models.mdn_rnn import gmm_los... | 6,358 | 35.337143 | 140 | py |
ReAgent | ReAgent-master/reagent/training/world_model/seq2reward_trainer.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import logging
import reagent.core.types as rlt
import torch
import torch.nn as nn
import torch.nn.functional as F
from reagent.core.parameters import Seq2RewardTrainerParameters
from reagent.models.fully_connected_network ... | 9,712 | 34.841328 | 88 | py |
ReAgent | ReAgent-master/reagent/training/world_model/compress_model_trainer.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import logging
import reagent.core.types as rlt
import torch
import torch.nn.functional as F
from reagent.core.parameters import Seq2RewardTrainerParameters
from reagent.core.types import FeatureData
from reagent.models.ful... | 4,414 | 34.894309 | 91 | py |
ReAgent | ReAgent-master/reagent/training/cfeval/bandit_reward_network_trainer.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import logging
from typing import Optional
import numpy as np
import reagent.core.types as rlt
import torch
from reagent.core.dataclasses import field
from reagent.models.base import ModelBase
from reagent.optimizer.union i... | 4,678 | 36.134921 | 85 | py |
ReAgent | ReAgent-master/reagent/training/ranking/seq2slate_attn_trainer.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import logging
import numpy as np
import reagent.core.types as rlt
import torch
import torch.nn as nn
from reagent.core.dataclasses import field
from reagent.model_utils.seq2slate_utils import Seq2SlateMode
from reagent.mode... | 6,103 | 38.636364 | 88 | py |
ReAgent | ReAgent-master/reagent/training/ranking/seq2slate_sim_trainer.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import logging
from itertools import permutations
from typing import List, Optional
import numpy as np
import reagent.core.types as rlt
import torch
import torch.nn as nn
from reagent.core.dataclasses import field
from reage... | 7,437 | 37.14359 | 88 | py |
ReAgent | ReAgent-master/reagent/training/ranking/seq2slate_trainer.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import logging
from typing import List, Optional, Tuple
import reagent.core.types as rlt
import torch
import torch.nn as nn
import torch.nn.functional as F
from reagent.core.dataclasses import field
from reagent.core.paramet... | 10,466 | 37.340659 | 127 | py |
ReAgent | ReAgent-master/reagent/training/ranking/helper.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
from typing import Optional
import torch
from reagent.core.parameters_seq2slate import IPSClamp, IPSClampMethod
def ips_clamp(impt_smpl, ips_clamp: Optional[IPSClamp]):
if not ips_clamp:
return impt_smpl.clone(... | 627 | 33.888889 | 83 | py |
ReAgent | ReAgent-master/reagent/training/ranking/seq2slate_tf_trainer.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import logging
from typing import List, Optional, Tuple
import reagent.core.types as rlt
import torch
import torch.nn as nn
import torch.nn.functional as F
from reagent.core.dataclasses import field
from reagent.core.paramet... | 5,504 | 34.980392 | 90 | py |
ReAgent | ReAgent-master/reagent/models/dueling_q_network.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import logging
from typing import List, Optional, Tuple, Union
import numpy as np
import torch
from reagent.core import types as rlt
from reagent.core.tensorboardX import SummaryWriterContext
from reagent.models.base import... | 7,899 | 32.617021 | 91 | py |
ReAgent | ReAgent-master/reagent/models/base.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
from copy import deepcopy
from typing import Any, Optional
import torch.nn as nn
from reagent.core import types as rlt
# add ABCMeta once https://github.com/sphinx-doc/sphinx/issues/5995 is fixed
class ModelBase(nn.Module... | 1,759 | 29.877193 | 108 | py |
ReAgent | ReAgent-master/reagent/models/actor.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import math
from typing import List, Optional
import torch
from reagent.core import types as rlt
from reagent.core.parameters import CONTINUOUS_TRAINING_ACTION_RANGE
from reagent.core.tensorboardX import SummaryWriterContex... | 11,437 | 37.641892 | 122 | py |
ReAgent | ReAgent-master/reagent/models/embedding_bag_concat.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
from typing import Dict, List
import torch
from reagent.core import types as rlt
from reagent.models.base import ModelBase
class EmbeddingBagConcat(ModelBase):
"""
Concatenating embedding with float features befor... | 3,303 | 33.778947 | 92 | py |
ReAgent | ReAgent-master/reagent/models/convolutional_network.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import collections
import logging
import math
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.nn.init as init
from reagent.models.fully_connected_network import FullyConnec... | 3,256 | 32.234694 | 85 | py |
ReAgent | ReAgent-master/reagent/models/seq2slate_reward.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import copy
import logging
from typing import List
import torch
import torch.nn as nn
import torch.nn.functional as F
from reagent.core import types as rlt
from reagent.core.torch_utils import gather
from reagent.model_utils... | 15,673 | 35.793427 | 87 | py |
ReAgent | ReAgent-master/reagent/models/categorical_dqn.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import torch
import torch.nn.functional as F
from reagent.core import types as rlt
from reagent.models.base import ModelBase
class CategoricalDQN(ModelBase):
def __init__(
self,
distributional_network: ... | 1,055 | 29.171429 | 71 | py |
ReAgent | ReAgent-master/reagent/models/dqn.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
from typing import Optional, Union
import numpy as np
import torch
from reagent.core import types as rlt
from reagent.models.fully_connected_network import (
FloatFeatureFullyConnected,
)
INVALID_ACTION_CONSTANT = -1e... | 1,541 | 27.555556 | 91 | py |
ReAgent | ReAgent-master/reagent/models/mlp_scorer.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import reagent.core.types as rlt
import torch
from reagent.models.base import ModelBase
class MLPScorer(ModelBase):
"""
Log-space in and out
"""
def __init__(
self,
mlp: torch.nn.Module,
... | 1,043 | 24.463415 | 79 | py |
ReAgent | ReAgent-master/reagent/models/mdn_rnn.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import logging
from collections import deque
from typing import NamedTuple
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as f
from reagent.core import types as rlt
from reagent.core.torch_u... | 8,467 | 35.5 | 87 | py |
ReAgent | ReAgent-master/reagent/models/fully_connected_network.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import logging
import math
from typing import List, Optional
import torch
import torch.nn as nn
import torch.nn.init as init
from reagent.core import types as rlt
from reagent.models.base import ModelBase
logger = logging... | 5,648 | 31.653179 | 88 | py |
ReAgent | ReAgent-master/reagent/models/seq2reward_model.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
from typing import Optional
import torch
import torch.nn as nn
from reagent.core import types as rlt
from reagent.models.base import ModelBase
class Seq2RewardNetwork(ModelBase):
def __init__(self, state_dim, action_d... | 3,177 | 33.923077 | 88 | py |
ReAgent | ReAgent-master/reagent/models/cem_planner.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
"""
A network which implements a cross entropy method-based planner
The planner plans the best next action based on simulation data generated by
an ensemble of world models.
The idea is inspired by: https://arxiv.org/abs/18... | 13,047 | 40.686901 | 88 | py |
ReAgent | ReAgent-master/reagent/models/bcq.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import torch
from reagent.models.base import ModelBase
class BatchConstrainedDQN(ModelBase):
def __init__(self, state_dim, q_network, imitator_network, bcq_drop_threshold):
super().__init__()
assert sta... | 1,239 | 40.333333 | 83 | py |
ReAgent | ReAgent-master/reagent/models/seq2slate.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import logging
import math
from typing import Optional, NamedTuple
import torch
import torch.nn as nn
import torch.nn.modules.transformer as transformer
from reagent.core import types as rlt
from reagent.core.configuration i... | 37,382 | 37.029502 | 92 | py |
ReAgent | ReAgent-master/reagent/models/critic.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
from typing import List
import torch
from reagent.core import types as rlt
from reagent.models.base import ModelBase
from reagent.models.fully_connected_network import FullyConnectedNetwork
class FullyConnectedCritic(Mode... | 2,106 | 35.327586 | 84 | py |
ReAgent | ReAgent-master/reagent/models/containers.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import torch.nn as nn
from reagent.models.base import ModelBase
class Sequential(
nn.Sequential, # type: ignore
ModelBase,
):
"""
Used this instead of torch.nn.Sequential to automate model tracing
"""
... | 535 | 23.363636 | 71 | py |
ReAgent | ReAgent-master/reagent/models/synthetic_reward.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import logging
import math
from typing import List
import torch
import torch.nn as nn
import torch.nn.functional as F
from reagent.core import parameters as rlp
from reagent.core import types as rlt
from reagent.models impor... | 19,664 | 36.033898 | 167 | py |
ReAgent | ReAgent-master/reagent/models/no_soft_update_embedding.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import copy
import torch.nn as nn
class NoSoftUpdateEmbedding(nn.Embedding):
"""
Use this instead of vanilla Embedding module to avoid soft-updating the embedding
table in the target network.
"""
def ... | 377 | 21.235294 | 85 | py |
ReAgent | ReAgent-master/reagent/models/world_model.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import torch
from reagent.core import types as rlt
from reagent.models.base import ModelBase
from reagent.models.mdn_rnn import MDNRNN
class MemoryNetwork(ModelBase):
def __init__(
self, state_dim, action_dim, ... | 1,722 | 30.907407 | 82 | py |
ReAgent | ReAgent-master/reagent/test/mab/test_ucb.py | import unittest
from io import BytesIO
import numpy as np
import numpy.testing as npt
import torch
from parameterized import parameterized
from reagent.mab.ucb import (
UCBTunedBernoulli,
MetricUCB,
UCBTuned,
UCB1,
_get_arm_indices,
_place_values_at_indices,
)
class TestUCButils(unittest.Test... | 8,809 | 34.959184 | 88 | py |
ReAgent | ReAgent-master/reagent/test/evaluation/test_evaluation_data_page.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import logging
import unittest
from typing import Optional
import numpy as np
import torch
import torch.nn as nn
from reagent.core import types as rlt
from reagent.evaluation.doubly_robust_estimator import DoublyRobustEstim... | 8,858 | 38.726457 | 87 | py |
ReAgent | ReAgent-master/reagent/test/evaluation/test_ope_integration.py | import logging
import random
import unittest
import numpy as np
import torch
from reagent.core import types as rlt
from reagent.evaluation.evaluation_data_page import EvaluationDataPage
from reagent.evaluation.ope_adapter import (
OPEstimatorAdapter,
SequentialOPEstimatorAdapter,
)
from reagent.ope.estimators.... | 13,472 | 39.338323 | 165 | py |
ReAgent | ReAgent-master/reagent/test/core/aggregators_test.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import unittest
import torch
from reagent.core.aggregators import ActionCountAggregator
class ActionCountAggregatorTest(unittest.TestCase):
def setUp(self):
self.actions = ["A", "B", "C"]
key = "logge... | 1,360 | 31.404762 | 71 | py |
ReAgent | ReAgent-master/reagent/test/training/test_ars_optimizer.py | #!/usr/bin/env python3
import unittest
import numpy as np
import torch
from reagent.training.gradient_free.ars_util import ARSOptimizer
class TestARSOptimizer(unittest.TestCase):
def metric(self, x):
# Ackley Function
# https://www.sfu.ca/~ssurjano/ackley.html
x *= 100
return (
... | 2,041 | 33.610169 | 73 | py |
ReAgent | ReAgent-master/reagent/test/training/test_qrdqn.py | #!/usr/bin/env python3
import unittest
import torch
from reagent.core.parameters import EvaluationParameters, RLParameters
from reagent.core.types import FeatureData, DiscreteDqnInput, ExtraData
from reagent.evaluation.evaluator import get_metrics_to_score
from reagent.models.dqn import FullyConnectedDQN
from reagent... | 8,027 | 39.14 | 88 | py |
ReAgent | ReAgent-master/reagent/test/training/test_synthetic_reward_training.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import logging
import unittest
import pytorch_lightning as pl
import torch
from reagent.core import parameters as rlp
from reagent.core import types as rlt
from reagent.models.synthetic_reward import (
SyntheticRewardNe... | 13,181 | 33.781003 | 86 | py |
ReAgent | ReAgent-master/reagent/test/training/test_multi_stage_trainer.py | #!/usr/bin/env python3
import unittest
from typing import List
import pytorch_lightning as pl
import torch
import torch.nn as nn
import torch.optim as optim
from reagent.reporting import ReporterBase, CompoundReporter
from reagent.training import ReAgentLightningModule, MultiStageTrainer
from torch.utils.data import ... | 5,966 | 31.606557 | 83 | py |
ReAgent | ReAgent-master/reagent/test/training/test_crr.py | import unittest
import torch
from reagent.core.parameters import EvaluationParameters, RLParameters
from reagent.core.types import FeatureData, DiscreteDqnInput, ExtraData
from reagent.evaluation.evaluator import get_metrics_to_score
from reagent.models.actor import FullyConnectedActor
from reagent.models.dqn import F... | 10,153 | 41.13278 | 108 | py |
ReAgent | ReAgent-master/reagent/test/training/test_ppo.py | import unittest
from collections import defaultdict
from unittest import mock
import torch
from reagent.core.types import PolicyGradientInput
from reagent.evaluation.evaluator import get_metrics_to_score
from reagent.gym.policies.policy import Policy
from reagent.gym.policies.samplers.discrete_sampler import SoftmaxAc... | 7,870 | 37.583333 | 92 | py |
ReAgent | ReAgent-master/reagent/test/world_model/test_seq2reward.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import logging
import os
import random
import unittest
from typing import Optional
import numpy as np
import pytorch_lightning as pl
import torch
import torch.nn as nn
from parameterized import parameterized
from reagent.co... | 16,680 | 34.719486 | 88 | py |
ReAgent | ReAgent-master/reagent/test/world_model/test_mdnrnn.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import logging
import unittest
import numpy as np
import torch
from reagent.core.parameters import MDNRNNTrainerParameters
from reagent.models.mdn_rnn import MDNRNNMemoryPool, gmm_loss
from reagent.models.world_model import... | 7,353 | 37.705263 | 87 | py |
ReAgent | ReAgent-master/reagent/test/world_model/simulated_world_model.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import torch
import torch.nn as nn
class SimulatedWorldModel(nn.Module):
"""
A world model used for simulation. Underlying is an RNN with fixed
parameters. Given a sequence of actions and states, it outputs the ... | 2,425 | 32.232877 | 88 | py |
ReAgent | ReAgent-master/reagent/test/models/test_bcq.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import logging
import unittest
import numpy.testing as npt
import torch
import torch.nn.init as init
from reagent.core import types as rlt
from reagent.models.bcq import BatchConstrainedDQN
from reagent.models.dqn import Fu... | 3,184 | 33.619565 | 88 | py |
ReAgent | ReAgent-master/reagent/test/models/test_synthetic_reward_net.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import logging
import unittest
import torch
from reagent.core import parameters as rlp
from reagent.models.synthetic_reward import (
SingleStepSyntheticRewardNet,
SequenceSyntheticRewardNet,
TransformerSynthetic... | 7,718 | 33.306667 | 82 | py |
ReAgent | ReAgent-master/reagent/test/models/test_actor.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import logging
import unittest
import numpy.testing as npt
import torch
from reagent.models.actor import (
DirichletFullyConnectedActor,
FullyConnectedActor,
GaussianFullyConnectedActor,
)
from reagent.test.mode... | 5,180 | 30.210843 | 87 | py |
ReAgent | ReAgent-master/reagent/test/models/test_no_soft_update_embedding.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import copy
import unittest
import numpy.testing as npt
import torch
import torch.nn as nn
from reagent.models.no_soft_update_embedding import NoSoftUpdateEmbedding
class Model(nn.Module):
def __init__(self):
... | 2,326 | 32.724638 | 86 | py |
ReAgent | ReAgent-master/reagent/test/models/test_base.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import dataclasses
import logging
import unittest
from typing import Any
import torch
import torch.nn as nn
from reagent.core import types as rlt
from reagent.models.base import ModelBase
from reagent.test.models.test_utils... | 1,423 | 23.982456 | 87 | py |
ReAgent | ReAgent-master/reagent/test/models/test_utils.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import logging
import numpy.testing as npt
import torch
logger = logging.getLogger(__name__)
def check_save_load(
self,
model,
expected_num_params,
expected_num_inputs,
expected_num_outputs,
chec... | 695 | 20.090909 | 71 | py |
ReAgent | ReAgent-master/reagent/test/samplers/test_frechet_sort.py | #!/usr/bin/env python3
import torch
from reagent.samplers.frechet import FrechetSort
from reagent.test.base.horizon_test_base import HorizonTestBase
class FrechetSortTest(HorizonTestBase):
def test_log_prob(self):
scores = torch.tensor(
[
[1.0, 2.0, 3.0, 4.0, 5.0],
... | 2,434 | 29.061728 | 76 | py |
ReAgent | ReAgent-master/reagent/test/base/test_tensorboardX.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import unittest
from tempfile import TemporaryDirectory
from unittest.mock import MagicMock, call
import torch
from reagent.core.tensorboardX import SummaryWriterContext, summary_writer_context
from reagent.test.base.horizo... | 5,172 | 42.470588 | 88 | py |
ReAgent | ReAgent-master/reagent/test/base/horizon_test_base.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
import random
import unittest
from typing import Callable
import numpy as np
import torch
from reagent.core.configuration import make_config_class
from reagent.core.tensorboardX import SummaryWriterContext
fro... | 1,173 | 25.681818 | 82 | py |
ReAgent | ReAgent-master/reagent/test/base/test_utils.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import unittest
import numpy as np
import numpy.testing as npt
import torch
from reagent.core.torch_utils import masked_softmax, rescale_torch_tensor
class TestUtils(unittest.TestCase):
def test_rescale_torch_tensor(s... | 2,836 | 37.337838 | 84 | py |
ReAgent | ReAgent-master/reagent/test/lite/test_combo_optimizer.py | #!/usr/bin/env python3
import random
import unittest
from collections import defaultdict
from typing import Dict
import nevergrad as ng
import numpy as np
import torch
import torch.nn as nn
from reagent.lite.optimizer import (
PolicyGradientOptimizer,
GumbelSoftmaxOptimizer,
QLearningOptimizer,
NeverG... | 25,061 | 37.795666 | 135 | py |
ReAgent | ReAgent-master/reagent/test/optimizer/test_make_optimizer.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import unittest
import torch
from reagent.optimizer.uninferrable_optimizers import Adam
from reagent.optimizer.uninferrable_schedulers import (
CosineAnnealingLR,
CosineAnnealingWarmRestarts,
ExponentialLR,
... | 2,523 | 33.108108 | 88 | py |
ReAgent | ReAgent-master/reagent/test/workflow/reagent_sql_test_base.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import logging
import os
import random
import shutil
import numpy as np
import torch
from pyspark import SparkConf
from reagent.data.spark_utils import DEFAULT_SPARK_CONFIG
# pyre-fixme[21]: Could not find `sparktestingbas... | 2,464 | 29.060976 | 80 | py |
ReAgent | ReAgent-master/reagent/test/workflow/test_oss_workflows.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import json
import os
import unittest
import zipfile
from typing import Dict
from unittest.mock import patch
import reagent
# pyre-fixme[21]: Could not find module `reagent.workflow.cli`.
import reagent.workflow.cli as cli... | 4,310 | 32.944882 | 86 | py |
ReAgent | ReAgent-master/reagent/test/replay_memory/extra_replay_buffer_test.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import logging
import numpy as np
import numpy.testing as npt
import torch
from reagent.replay_memory.circular_replay_buffer import ReplayBuffer
from reagent.test.base.horizon_test_base import HorizonTestBase
logger = log... | 16,943 | 36.653333 | 102 | py |
ReAgent | ReAgent-master/reagent/test/replay_memory/circular_replay_buffer_test.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
# Copyright 2018 The Dopamine Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# ... | 21,389 | 42.038229 | 88 | py |
ReAgent | ReAgent-master/reagent/test/ranking/test_seq2slate_inference.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import logging
import random
import unittest
import numpy as np
import torch
import torch
from reagent.core.parameters import (
NormalizationData,
NormalizationParameters,
)
from reagent.model_utils.seq2slate_utils i... | 3,424 | 32.578431 | 87 | py |
ReAgent | ReAgent-master/reagent/test/ranking/seq2slate_utils.py | import logging
import math
import tempfile
from itertools import permutations
import pytorch_lightning as pl
import reagent.core.types as rlt
import torch
import torch.nn as nn
from reagent.core.parameters import Seq2SlateParameters
from reagent.core.parameters_seq2slate import LearningMethod, SimulationParameters
fro... | 11,291 | 29.518919 | 88 | py |
ReAgent | ReAgent-master/reagent/test/ranking/test_seq2slate_on_policy.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import itertools
import logging
import random
import unittest
from collections import defaultdict
from itertools import permutations
import numpy as np
import pytest
import reagent.core.types as rlt
import torch
import torch... | 12,496 | 32.414439 | 90 | py |
ReAgent | ReAgent-master/reagent/test/ranking/test_seq2slate_trainer.py | import copy
import itertools
import logging
import random
import unittest
from itertools import permutations
import numpy as np
import numpy.testing as npt
import pytorch_lightning as pl
import reagent.core.types as rlt
import torch
from parameterized import parameterized
from reagent.core.parameters import Seq2SlateP... | 19,844 | 34.628366 | 103 | py |
ReAgent | ReAgent-master/reagent/test/ranking/test_seq2slate_simulation.py | import random
import unittest
import numpy as np
import pytest
import torch
from reagent.test.ranking.seq2slate_utils import (
MODEL_TRANSFORMER,
SIMULATION,
run_seq2slate_tsp,
)
class TestSeq2SlateSimulation(unittest.TestCase):
def setUp(self):
np.random.seed(0)
random.seed(0)
... | 2,194 | 26.098765 | 84 | py |
ReAgent | ReAgent-master/reagent/test/ranking/test_seq2slate_off_policy.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import logging
import random
import unittest
import numpy as np
import pytest
import torch
from reagent.test.ranking.seq2slate_utils import (
MODEL_TRANSFORMER,
OFF_POLICY,
run_seq2slate_tsp,
)
logger = logging... | 2,344 | 25.954023 | 84 | py |
ReAgent | ReAgent-master/reagent/test/net_builder/test_value_net_builder.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import unittest
import torch
from reagent.core.parameters import NormalizationData, NormalizationParameters
from reagent.core.types import FeatureData
from reagent.net_builder import value
from reagent.net_builder.unions im... | 1,141 | 34.6875 | 78 | py |
ReAgent | ReAgent-master/reagent/test/net_builder/test_synthetic_reward_net_builder.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import unittest
import numpy.testing as npt
import torch
from reagent.core import parameters as rlp
from reagent.core import types as rlt
from reagent.core.fb_checker import IS_FB_ENVIRONMENT
from reagent.core.parameters im... | 11,061 | 37.409722 | 98 | py |
ReAgent | ReAgent-master/reagent/test/preprocessing/test_sparse_to_dense.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import unittest
import torch
from reagent.preprocessing import normalization
from reagent.preprocessing.sparse_to_dense import (
PythonSparseToDenseProcessor,
StringKeySparseToDenseProcessor,
)
class TestSparseToD... | 2,754 | 36.739726 | 82 | py |
ReAgent | ReAgent-master/reagent/test/preprocessing/test_preprocessing.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import unittest
import numpy as np
import numpy.testing as npt
import six
import torch
from reagent.preprocessing import identify_types, normalization, transforms
from reagent.preprocessing.identify_types import BOXCOX, CON... | 16,423 | 39.156479 | 88 | py |
ReAgent | ReAgent-master/reagent/test/preprocessing/test_postprocessing.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import unittest
import numpy.testing as npt
import torch
from reagent.preprocessing.identify_types import CONTINUOUS_ACTION, DO_NOT_PREPROCESS
from reagent.preprocessing.normalization import NormalizationParameters
from rea... | 1,669 | 36.954545 | 86 | py |
ReAgent | ReAgent-master/reagent/test/preprocessing/test_transforms.py | import unittest
from copy import deepcopy
from typing import List
from unittest.mock import Mock, patch
import numpy as np
import reagent.core.types as rlt
import torch
from reagent.preprocessing import transforms
from reagent.preprocessing.types import InputColumn
class TestTransforms(unittest.TestCase):
def se... | 21,051 | 38.349533 | 102 | py |
ReAgent | ReAgent-master/reagent/test/prediction/test_predictor_wrapper.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import random
import unittest
import numpy.testing as npt
import reagent.core.types as rlt
import reagent.models as models
import torch
from reagent.model_utils.seq2slate_utils import Seq2SlateMode, Seq2SlateOutputArch
from... | 16,078 | 38.898263 | 88 | py |
ReAgent | ReAgent-master/reagent/test/prediction/test_model_with_preprocessor.py | import unittest
import numpy.testing as npt
import torch
from reagent.model_utils.seq2slate_utils import Seq2SlateOutputArch
from reagent.models.seq2slate import Seq2SlateTransformerNet
from reagent.prediction.predictor_wrapper import Seq2SlateWithPreprocessor
from reagent.preprocessing.preprocessor import Preprocesso... | 3,422 | 41.7875 | 88 | py |
ReAgent | ReAgent-master/reagent/test/prediction/test_prediction_utils.py | import torch
from reagent.preprocessing.identify_types import CONTINUOUS, CONTINUOUS_ACTION
from reagent.preprocessing.normalization import NormalizationParameters
def _cont_norm():
return NormalizationParameters(feature_type=CONTINUOUS, mean=0.0, stddev=1.0)
def _cont_action_norm():
return NormalizationPar... | 970 | 32.482759 | 84 | py |
ReAgent | ReAgent-master/reagent/scripts/hparam_tuning.py | #!/usr/bin/env python3
# (c) Facebook, Inc. and its affiliates. Confidential and proprietary.
import logging # isort:skip
logging.disable() # isort:skip
import copy
import json
import os
from typing import Any, Callable, Dict, List, Tuple, Optional
import numpy as np
import torch.multiprocessing as mp
from ax.ser... | 7,864 | 38.923858 | 123 | py |
ReAgent | ReAgent-master/reagent/publishers/file_system_publisher.py | #!/usr/bin/env python3
import logging
import os
from typing import Dict, Optional
from reagent.core.dataclasses import dataclass
from reagent.core.result_types import NoPublishingResults
from reagent.model_managers.model_manager import ModelManager
from reagent.publishers.model_publisher import ModelPublisher
from re... | 3,502 | 34.383838 | 86 | py |
ReAgent | ReAgent-master/reagent/samplers/frechet.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import logging
import math
from typing import Optional
import reagent.core.types as rlt
import torch
import torch.nn.functional as F
from reagent.core.configuration import resolve_defaults
from reagent.gym.types import Sampl... | 6,562 | 39.512346 | 134 | py |
ReAgent | ReAgent-master/reagent/model_managers/model_manager.py | #!/usr/bin/env python3
import abc
import logging
from typing import Dict, List, Optional, Tuple
import pytorch_lightning as pl
import torch
from reagent.core.dataclasses import dataclass
from reagent.core.parameters import NormalizationData
from reagent.data.reagent_data_module import ReAgentDataModule
from reagent.r... | 7,097 | 33.965517 | 133 | py |
ReAgent | ReAgent-master/reagent/model_managers/discrete_dqn_base.py | #!/usr/bin/env python3
import abc
import logging
from dataclasses import replace
from typing import Dict, List, Optional, Tuple
from reagent.core import types as rlt
from reagent.core.dataclasses import dataclass, field
from reagent.core.parameters import (
EvaluationParameters,
NormalizationData,
Normali... | 7,304 | 36.081218 | 87 | py |
ReAgent | ReAgent-master/reagent/model_managers/actor_critic_base.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import logging
from dataclasses import replace
from typing import Dict, List, Optional, Tuple
import numpy as np
import reagent.core.types as rlt
import torch
from reagent.core.dataclasses import dataclass, field
from reage... | 9,318 | 36.882114 | 88 | py |
ReAgent | ReAgent-master/reagent/model_managers/slate_q_base.py | #!/usr/bin/env python3
import logging
from typing import Dict, List, Optional, Tuple
import reagent.core.types as rlt
from reagent.core.dataclasses import dataclass
from reagent.core.parameters import NormalizationData, NormalizationKey
from reagent.data import DataFetcher, ReAgentDataModule
from reagent.gym.policies.... | 3,947 | 38.48 | 86 | py |
ReAgent | ReAgent-master/reagent/model_managers/parametric_dqn_base.py | #!/usr/bin/env python3
import logging
from dataclasses import replace
from typing import Dict, List, Optional, Tuple
import reagent.core.types as rlt
from reagent.core.dataclasses import dataclass, field
from reagent.core.parameters import (
EvaluationParameters,
NormalizationData,
NormalizationKey,
)
fro... | 7,398 | 38.356383 | 88 | py |
ReAgent | ReAgent-master/reagent/model_managers/discrete/discrete_qrdqn.py | #!/usr/bin/env python3
import logging
from typing import Dict, Optional
import torch
from reagent.core.dataclasses import dataclass, field
from reagent.core.parameters import NormalizationData, NormalizationKey, param_hash
from reagent.evaluation.evaluator import get_metrics_to_score
from reagent.model_managers.discr... | 4,782 | 35.792308 | 88 | py |
ReAgent | ReAgent-master/reagent/model_managers/discrete/discrete_dqn.py | #!/usr/bin/env python3
import logging
from typing import Dict, Optional
import torch
from reagent.core.dataclasses import dataclass, field
from reagent.core.parameters import NormalizationData, NormalizationKey, param_hash
from reagent.evaluation.evaluator import get_metrics_to_score
from reagent.model_managers.discr... | 6,355 | 35.32 | 85 | py |
ReAgent | ReAgent-master/reagent/model_managers/discrete/discrete_crr.py | #!/usr/bin/env python3
# Note: this file is modeled after td3.py
import logging
from typing import Dict, Optional
import numpy as np
import reagent.core.types as rlt
import torch
from reagent.core.dataclasses import dataclass, field
from reagent.core.parameters import (
EvaluationParameters,
NormalizationDat... | 11,523 | 37.033003 | 101 | py |
ReAgent | ReAgent-master/reagent/model_managers/discrete/discrete_c51dqn.py | #!/usr/bin/env python3
import logging
from typing import Dict
from typing import Optional
import torch
from reagent.core.dataclasses import dataclass, field
from reagent.core.parameters import param_hash, NormalizationData, NormalizationKey
from reagent.model_managers.discrete_dqn_base import DiscreteDQNBase
from rea... | 3,985 | 37.699029 | 85 | py |
ReAgent | ReAgent-master/reagent/model_managers/model_based/cross_entropy_method.py | #!/usr/bin/env python3
import logging
from typing import Optional, Dict
import numpy as np
import reagent.core.types as rlt
import torch
from reagent.core.dataclasses import dataclass, field
from reagent.core.parameters import (
CEMTrainerParameters,
param_hash,
NormalizationData,
NormalizationKey,
)
... | 5,783 | 38.346939 | 88 | py |
ReAgent | ReAgent-master/reagent/model_managers/model_based/synthetic_reward.py | #!/usr/bin/env python3
import logging
from dataclasses import replace
from typing import Dict, List, Optional, Tuple
import reagent.core.types as rlt
import torch
from reagent.core.dataclasses import dataclass, field
from reagent.core.parameters import (
EvaluationParameters,
NormalizationData,
Normalizat... | 9,887 | 38.552 | 133 | py |
ReAgent | ReAgent-master/reagent/model_managers/parametric/parametric_dqn.py | #!/usr/bin/env python3
import logging
from typing import Dict, Optional
import torch
from reagent.core.dataclasses import dataclass, field
from reagent.core.parameters import param_hash, NormalizationData, NormalizationKey
from reagent.evaluation.evaluator import get_metrics_to_score
from reagent.model_managers.param... | 3,127 | 36.686747 | 84 | py |
ReAgent | ReAgent-master/reagent/model_managers/policy_gradient/reinforce.py | #!/usr/bin/env python3
import logging
from typing import Dict, Optional
import torch
from reagent.core import types as rlt
from reagent.core.dataclasses import dataclass, field
from reagent.core.parameters import NormalizationData
from reagent.core.parameters import NormalizationKey
from reagent.core.parameters impor... | 4,827 | 36.426357 | 86 | py |
ReAgent | ReAgent-master/reagent/model_managers/policy_gradient/ppo.py | #!/usr/bin/env python3
import logging
from typing import Dict, Optional
import torch
from reagent.core import types as rlt
from reagent.core.dataclasses import dataclass, field
from reagent.core.parameters import NormalizationData
from reagent.core.parameters import NormalizationKey
from reagent.core.parameters impor... | 4,753 | 36.433071 | 86 | py |
ReAgent | ReAgent-master/reagent/model_managers/actor_critic/sac.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import logging
from typing import Dict, Optional
import torch
from reagent.core.dataclasses import dataclass, field
from reagent.core.parameters import NormalizationData, NormalizationKey, param_hash
from reagent.model_man... | 5,112 | 36.321168 | 85 | py |
ReAgent | ReAgent-master/reagent/model_managers/actor_critic/td3.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import logging
from typing import Dict, Optional
import torch
from reagent.core.dataclasses import dataclass, field
from reagent.core.parameters import (
EvaluationParameters,
NormalizationData,
NormalizationKe... | 4,213 | 35.017094 | 87 | py |
ReAgent | ReAgent-master/reagent/model_managers/ranking/slate_q.py | #!/usr/bin/env python3
import logging
from typing import Optional, Dict
import torch
from reagent.core.dataclasses import dataclass, field
from reagent.core.parameters import param_hash, NormalizationData, NormalizationKey
from reagent.model_managers.slate_q_base import SlateQBase
from reagent.models.base import Mode... | 2,830 | 34.3875 | 83 | py |
ReAgent | ReAgent-master/reagent/lite/optimizer.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import abc
import heapq
import logging
from collections import defaultdict, deque
from math import floor
from typing import Callable, Dict, Tuple, Optional, List, Any
import nevergrad as ng
import numpy as np
import torch
i... | 46,935 | 36.821112 | 124 | py |
ReAgent | ReAgent-master/reagent/data/oss_data_fetcher.py | #!/usr/bin/env python3
import logging
from typing import List, Optional, Tuple
# pyre-fixme[21]: Could not find `pyspark`.
# pyre-fixme[21]: Could not find `pyspark`.
from pyspark.sql.functions import col, crc32, explode, map_keys, udf
from pyspark.sql.types import (
ArrayType,
BooleanType,
FloatType,
... | 18,591 | 37.255144 | 88 | py |
ReAgent | ReAgent-master/reagent/data/reagent_data_module.py | #!/usr/bin/env python3
import abc
from typing import Dict, List, Optional
import pytorch_lightning as pl
from reagent.core.parameters import NormalizationData
class ReAgentDataModule(pl.LightningDataModule):
@abc.abstractmethod
def get_normalization_data_map(
self,
keys: Optional[List[str]] ... | 380 | 21.411765 | 53 | py |
ReAgent | ReAgent-master/reagent/data/manual_data_module.py | #!/usr/bin/env python3
import abc
import logging
import pickle
from typing import NamedTuple, Dict, List, Optional, Tuple
logger = logging.getLogger(__name__)
try:
# pyre-fixme[21]: Could not find `petastorm`.
from petastorm import make_batch_reader
# pyre-fixme[21]: Could not find module `petastorm.py... | 10,842 | 33.753205 | 88 | py |
ReAgent | ReAgent-master/reagent/optimizer/scheduler_union.py | #!/usr/bin/env python3
import logging
from typing import List
import reagent.optimizer.uninferrable_schedulers as cannot_be_inferred
import torch
from reagent.core.configuration import make_config_class, param_hash
from reagent.core.fb_checker import IS_FB_ENVIRONMENT
from reagent.core.tagged_union import TaggedUnion... | 1,898 | 29.142857 | 86 | py |
ReAgent | ReAgent-master/reagent/optimizer/soft_update.py | #!/usr/bin/env python3
import torch
class SoftUpdate(torch.optim.Optimizer):
def __init__(self, target_params, source_params, tau=0.1):
"""
Perform soft-update on target_params. Soft-update gradually blends
source_params into target_params with this update equation:
target_pa... | 2,463 | 34.710145 | 91 | py |
ReAgent | ReAgent-master/reagent/optimizer/union.py | #!/usr/bin/env python3
import logging
from typing import List
import reagent.optimizer.uninferrable_optimizers as cannot_be_inferred
import torch
from reagent.core.configuration import make_config_class, param_hash
from reagent.core.tagged_union import TaggedUnion
from .optimizer import OptimizerConfig
from .utils i... | 1,781 | 27.741935 | 82 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.