python_code
stringlengths
0
4.04M
repo_name
stringlengths
7
58
file_path
stringlengths
5
147
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import os import sys import uuid import shutil import logging import datetime import importlib import traceback import contextlib import typ...
controllable_agent-main
controllable_agent/runner.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree.
controllable_agent-main
controllable_agent/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import time import concurrent.futures from pathlib import Path import pytest import submitit from . import executor as _exec def func(fail...
controllable_agent-main
controllable_agent/test_executor.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import re import itertools import subprocess from pathlib import Path import controllable_agent from . import runner def test_quadruped_g...
controllable_agent-main
controllable_agent/test_url_benchmark.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import time import logging import traceback import contextlib import nevergrad.common.typing as tp logger = logging.getLogger(__name__) ...
controllable_agent-main
controllable_agent/executor.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from __future__ import annotations import dataclasses import typing as tp import numpy as np from url_benchmark.agent.ddpg import MetaDict...
controllable_agent-main
url_benchmark/d4rl_benchmark.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import os import json import pdb # pylint: disable=unused-import import logging import dataclasses import typing as tp import warnings from...
controllable_agent-main
url_benchmark/pretrain.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import pdb # pylint: disable=unused-import import logging import dataclasses import typing as tp from url_benchmark import pretrain # NEE...
controllable_agent-main
url_benchmark/train_online.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import pdb # pylint: disable=unused-import import logging import dataclasses import typing as tp from url_benchmark import pretrain # NEE...
controllable_agent-main
url_benchmark/anytrain.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import pdb # pylint: disable=unused-import import token import tokenize import functools import typing as tp from io import BytesIO from co...
controllable_agent-main
url_benchmark/goals.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import functools import collections from collections import abc from concurrent import futures import time import uuid import json import ty...
controllable_agent-main
url_benchmark/hiplogs.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import typing as tp import sys from pathlib import Path import subprocess import pytest def _run(tmp_path: Path, **params: tp.Any) -> None...
controllable_agent-main
url_benchmark/test_pretrain.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import pdb # pylint: disable=unused-import import logging import dataclasses import typing as tp from url_benchmark import pretrain # NEE...
controllable_agent-main
url_benchmark/train_offline.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import subprocess import sys import tempfile import typing as tp from pathlib import Path import pytest import hydra import numpy as np from...
controllable_agent-main
url_benchmark/test_hiplogs.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree.
controllable_agent-main
url_benchmark/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import csv import logging import typing as tp from pathlib import Path import datetime from collections import defaultdict import torch imp...
controllable_agent-main
url_benchmark/logger.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import numpy as np from url_benchmark import replay_buffer as rb def test_batch() -> None: shapes = dict(obs=(4, 12), action=(5, 11), ...
controllable_agent-main
url_benchmark/test_replay_buffer.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import random import re import time import typing as tp import numpy as np import torch from torch import nn import torch.nn.fu...
controllable_agent-main
url_benchmark/utils.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from typing import List DOMAINS = [ 'walker', 'quadruped', 'jaco', 'point_mass_maze' 'cheetah' ] CHEETAH_TASKS = [ ...
controllable_agent-main
url_benchmark/dmc_benchmark.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import pdb # pylint: disable=unused-import import logging import typing as tp import dataclasses import collections from pathlib import Pat...
controllable_agent-main
url_benchmark/in_memory_replay_buffer.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import datetime import io import random import traceback import typing as tp from pathlib import Path from collections import defaultdict im...
controllable_agent-main
url_benchmark/replay_buffer.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import pdb # pylint: disable=unused-import import sys import unittest import dataclasses from collections import OrderedDict, deque import ...
controllable_agent-main
url_benchmark/dmc.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import pickle from url_benchmark.dmc import TimeStep from url_benchmark.in_memory_replay_buffer import ReplayBuffer from typing import List...
controllable_agent-main
url_benchmark/test_in_memory_replay_buffer.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import typing as tp import collections import numpy as np import pytest from url_benchmark import goals def test_basics() -> None: as...
controllable_agent-main
url_benchmark/test_goals.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from url_benchmark.goals import DmcReward import torch name = "walker_flip" load_replay_buffer = "/checkpoint/jrapin/ca/buffers/walker_rnd_...
controllable_agent-main
url_benchmark/relabel_buffer.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import pdb # pylint: disable=unused-import import warnings warnings.filterwarnings('ignore', category=DeprecationWarning) import os os.e...
controllable_agent-main
url_benchmark/play_behaviors.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import typing as tp from pathlib import Path import cv2 import imageio import numpy as np import wandb class VideoRecorder: def __init...
controllable_agent-main
url_benchmark/video.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import typing as tp import pytest from url_benchmark import dmc from url_benchmark.in_memory_replay_buffer import ReplayBuffer @pytest.mar...
controllable_agent-main
url_benchmark/test_dmc.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import typing as tp import enum import dm_env from dm_env import specs import numpy as np import matplotlib.pyplot as plt from url_benchmark...
controllable_agent-main
url_benchmark/gridworld/env.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree.
controllable_agent-main
url_benchmark/gridworld/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # pylint: disable=unused-import import pdb import copy import math import logging import dataclasses from collections import OrderedDict imp...
controllable_agent-main
url_benchmark/agent/sf.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # pylint: disable=unused-import import dataclasses import typing as tp import torch from hydra.core.config_store import ConfigStore from ....
controllable_agent-main
url_benchmark/agent/discrete_sf.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import pdb # pylint: disable=unused-import import typing as tp import dataclasses from collections import OrderedDict import logging import...
controllable_agent-main
url_benchmark/agent/new_aps.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # pylint: disable=unused-import import pdb import copy import math import logging import dataclasses from collections import OrderedDict imp...
controllable_agent-main
url_benchmark/agent/discrete_fb.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import dataclasses import typing as tp import torch from torch import nn from hydra.core.config_store import ConfigStore import omegaconf f...
controllable_agent-main
url_benchmark/agent/icm_apt.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # pylint: disable=unused-import import pdb import copy import math import logging import dataclasses from collections import OrderedDict imp...
controllable_agent-main
url_benchmark/agent/fb_ddpg.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import inspect import dataclasses from types import ModuleType import numpy as np import torch from url_benchmark import replay_buffer as rb...
controllable_agent-main
url_benchmark/agent/test_agent.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import typing as tp from collections import OrderedDict import numpy as np import torch from torch import nn import torch.nn.functional as ...
controllable_agent-main
url_benchmark/agent/smm.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import typing as tp import torch from torch import nn from url_benchmark import utils from .ddpg import DDPGAgent from url_benchmark.in_mem...
controllable_agent-main
url_benchmark/agent/icm.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import pdb # pylint: disable=unused-import import typing as tp from collections import OrderedDict import dataclasses import logging impor...
controllable_agent-main
url_benchmark/agent/goal_sm.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import pdb # pylint: disable=unused-import import typing as tp import dataclasses import numpy as np import torch from torch import nn impo...
controllable_agent-main
url_benchmark/agent/aps.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from .ddpg import DDPGAgent as DDPGAgent from .ddpg import DDPGAgentConfig as DDPGAgentConfig from .fb_ddpg import FBDDPGAgent as FBDDPGAgen...
controllable_agent-main
url_benchmark/agent/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # pylint: disable=unused-import import pdb import typing as tp import torch from url_benchmark import utils from .ddpg import DDPGAgent fro...
controllable_agent-main
url_benchmark/agent/max_ent.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import typing as tp import torch from torch import nn from url_benchmark import utils from .ddpg import DDPGAgent from url_benchmark.in_mem...
controllable_agent-main
url_benchmark/agent/disagreement.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import pdb # pylint: disable=unused-import import typing as tp from typing import Any, Dict import copy import dataclasses import torch from...
controllable_agent-main
url_benchmark/agent/rnd.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import typing as tp import dataclasses from typing import Any, Tuple from collections import OrderedDict import numpy as np import torch fr...
controllable_agent-main
url_benchmark/agent/ddpg.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # pylint: disable=unused-import import pdb import copy import math import logging import dataclasses from collections import OrderedDict imp...
controllable_agent-main
url_benchmark/agent/sf_svd.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import pdb # pylint: disable=unused-import import typing as tp from collections import OrderedDict import dataclasses import logging impor...
controllable_agent-main
url_benchmark/agent/goal_td3.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import typing as tp import dataclasses from copy import deepcopy import torch from torch import nn import torch.nn.functional as F from tor...
controllable_agent-main
url_benchmark/agent/proto.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import pdb # pylint: disable=unused-import import math import typing as tp import torch from torch import nn import torch.nn.functional as...
controllable_agent-main
url_benchmark/agent/fb_modules.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import dataclasses import typing as tp from typing import Any, Dict, Tuple import math from collections import OrderedDict import numpy as ...
controllable_agent-main
url_benchmark/agent/diayn.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # pylint: disable=unused-import import pdb import copy import math import logging import dataclasses from collections import OrderedDict imp...
controllable_agent-main
url_benchmark/agent/uvf.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # # Copyright 2019 The dm_control Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file ex...
controllable_agent-main
url_benchmark/custom_dmc_tasks/quadruped.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # # Copyright 2017 The dm_control Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file ex...
controllable_agent-main
url_benchmark/custom_dmc_tasks/point_mass_maze.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # # Copyright 2019 The dm_control Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file ex...
controllable_agent-main
url_benchmark/custom_dmc_tasks/jaco.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # # Copyright 2017 The dm_control Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file ex...
controllable_agent-main
url_benchmark/custom_dmc_tasks/walker.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import typing as tp from . import cheetah from . import walker from . import hopper from . import quadruped from . import jaco from . import...
controllable_agent-main
url_benchmark/custom_dmc_tasks/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # # Copyright 2017 The dm_control Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file ex...
controllable_agent-main
url_benchmark/custom_dmc_tasks/cheetah.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # # Copyright 2017 The dm_control Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file ex...
controllable_agent-main
url_benchmark/custom_dmc_tasks/hopper.py
""" Trigger the conda-forge.github.io Travis job to restart. """ import argparse import os import requests import six import conda_smithy.ci_register def rebuild_travis(repo_slug): headers = conda_smithy.ci_register.travis_headers() # If we don't specify the API version, we get a 404. # Also fix the ...
staged-recipes-master
.travis_scripts/trigger_travis_build.py
#!/usr/bin/env python """ Convert all recipes into feedstocks. This script is to be run in a TravisCI context, with all secret environment variables defined (BINSTAR_TOKEN, GH_TOKEN) Such as: export GH_TOKEN=$(cat ~/.conda-smithy/github.token) """ from __future__ import print_function from conda_build.metadata ...
staged-recipes-master
.travis_scripts/create_feedstocks.py
#!/usr/bin/env python """ Copyright (c) 2016, Continuum Analytics, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this l...
staged-recipes-master
.ci_support/compute_build_graph.py
import conda_build.conda_interface import networkx as nx import conda_build.api from compute_build_graph import construct_graph import argparse import os from collections import OrderedDict import sys def get_host_platform(): from sys import platform if platform == "linux" or platform == "linux2": ret...
staged-recipes-master
.ci_support/build_all.py
# ============================================================================== # # run.py # # usage: # # $ python run.py path/to/solver.prototxt path/to/machine_list.txt machines_per_batch CPU|1GPU|4GPU single_fc|many_fc (map_fcc_to_cc=)1|0 base_dir snapshot_input_dir(=None) snapshot_input_iter(=No...
Omnivore-master
run.py
# Generated by the protocol buffer compiler. DO NOT EDIT! # source: datum.proto import sys _b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1')) from google.protobuf import descriptor as _descriptor from google.protobuf import message as _message from google.protobuf import reflection as _reflect...
Omnivore-master
datum_pb2.py
#!/usr/bin/python # ============================================================================== # # omnivore.py # # usage: # # $ python omnivore.py config.txt # # ============================================================================== import os import sys import re # Regex # config file provides al...
Omnivore-master
omnivore.py
# ------------------------------------------------------------------------------ # Parameters # ------------------------------------------------------------------------------ NUM_COMPUTE = 1 dir = str(NUM_COMPUTE) + '_profile' out_name = dir # No ext needed, automatically will be .png # ----------------------------...
Omnivore-master
tools/profile/analyze.py
import os # ------------------------------------------------------------------------------ # Parameters # ------------------------------------------------------------------------------ hw_types = ['4GPU'] num_machines_per_group_list = [1,2,4,8] num_group_list = [32,16,8,4] num_runs = 2 time_per_exp = 3600*1 NUM_MACHI...
Omnivore-master
tools/util_scripts/experiment.py
import sys import numpy as np def makeColorwheel(): # color encoding scheme # adapted from the color circle idea described at # http://members.shaw.ca/quadibloc/other/colint.htm RY = 15 YG = 6 GC = 4 CB = 11 BM = 13 MR = 6 ncols = RY + YG + GC + CB + BM + MR colorwheel = np.zeros([ncols, 3]) # r g...
AR-Depth-main
flow_color.py
# Copyright 2017 Google Inc. All Rights Reserved. # # 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 # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or a...
CodeGen-main
CodeXGLUE/Text-Code/text-to-code/evaluator/bleu.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. import os import logging import argparse from bleu import _bleu import json logger = logging.getLogger(__name__) logging.basicConfig(level=logging.INFO) def main(): parser = argparse.ArgumentParser(description='Evaluate leaderboard predicti...
CodeGen-main
CodeXGLUE/Text-Code/text-to-code/evaluator/evaluator.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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 cop...
CodeGen-main
CodeXGLUE/Text-Code/text-to-code/code/run.py
# Copyright 2017 Google Inc. All Rights Reserved. # # 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 # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or a...
CodeGen-main
CodeXGLUE/Text-Code/text-to-code/code/bleu.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from __future__ import absolute_import, division, print_function import argparse import glob import logging import os import pickle import random import re import gc import shutil import json import numpy as np import torch from torch.utils.data...
CodeGen-main
CodeXGLUE/Text-Code/text-to-code/code/dataset.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. import torch import torch.nn as nn import torch from torch.autograd import Variable import copy class Seq2Seq(nn.Module): """ Build Seqence-to-Sequence. Parameters: * `encoder`- encoder of seq2seq model. e.g. roberta...
CodeGen-main
CodeXGLUE/Text-Code/text-to-code/code/beam.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. import logging import sys,json import numpy as np def read_answers(filename): answers={} with open(filename) as f: for line in f: line=line.strip() js=json.loads(line) answers[js['url']]=js['id...
CodeGen-main
CodeXGLUE/Text-Code/NL-code-search-Adv/evaluator/evaluator.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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 cop...
CodeGen-main
CodeXGLUE/Text-Code/NL-code-search-Adv/code/run.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import torch import torch.nn as nn import torch from torch.autograd import Variable import copy import torch.nn.functional as F from torch.nn import CrossEntropyLoss, MSELoss class Model(nn.Module): def __init__(self, encoder,config,...
CodeGen-main
CodeXGLUE/Text-Code/NL-code-search-Adv/code/model.py
#!/usr/bin/python ''' This script was adapted from the original version by hieuhoang1972 which is part of MOSES. ''' # $Id: bleu.py 1307 2007-03-14 22:22:36Z hieuhoang1972 $ '''Provides: cook_refs(refs, n=4): Transform a list of reference sentences as strings into a form usable by cook_test(). cook_test(test, refs...
CodeGen-main
CodeXGLUE/Code-Text/code-to-text/evaluator/evaluator.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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 cop...
CodeGen-main
CodeXGLUE/Code-Text/code-to-text/code/run.py
#!/usr/bin/python ''' This script was adapted from the original version by hieuhoang1972 which is part of MOSES. ''' # $Id: bleu.py 1307 2007-03-14 22:22:36Z hieuhoang1972 $ '''Provides: cook_refs(refs, n=4): Transform a list of reference sentences as strings into a form usable by cook_test(). cook_test(test, refs...
CodeGen-main
CodeXGLUE/Code-Text/code-to-text/code/bleu.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. import torch import torch.nn as nn import torch from torch.autograd import Variable import copy class Seq2Seq(nn.Module): """ Build Seqence-to-Sequence. Parameters: * `encoder`- encoder of seq2seq model. e.g...
CodeGen-main
CodeXGLUE/Code-Text/code-to-text/code/model.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. import logging import sys from sklearn.metrics import recall_score,precision_score,f1_score def read_answers(filename): answers={} with open(filename) as f: for line in f: line=line.strip() idx1,idx2,label...
CodeGen-main
CodeXGLUE/Code-Code/Clone-detection-BigCloneBench/evaluator/evaluator.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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 cop...
CodeGen-main
CodeXGLUE/Code-Code/Clone-detection-BigCloneBench/code/run.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. import torch import torch.nn as nn import torch from torch.autograd import Variable import copy import torch.nn.functional as F from torch.nn import CrossEntropyLoss, MSELoss class RobertaClassificationHead(nn.Module): """Head for sentence-l...
CodeGen-main
CodeXGLUE/Code-Code/Clone-detection-BigCloneBench/code/model.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( n ) : if n <= 1 : return False for i in range ( 2 , n ) : if n % i == 0 : retur...
CodeGen-main
data/transcoder_evaluation_gfg/python/PRIMALITY_TEST_SET_1_INTRODUCTION_AND_SCHOOL_METHOD.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( S , n ) : found = False S.sort ( ) for i in range ( n - 1 , - 1 , - 1 ) : for j in range ( 0 , ...
CodeGen-main
data/transcoder_evaluation_gfg/python/FIND_LARGEST_D_IN_ARRAY_SUCH_THAT_A_B_C_D.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( s ) : n = len ( s ) ; sub_count = ( n * ( n + 1 ) ) // 2 ; arr = [ 0 ] * sub_count ; index = 0 ; ...
CodeGen-main
data/transcoder_evaluation_gfg/python/LEXICOGRAPHICAL_CONCATENATION_SUBSTRINGS_STRING.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold(str1, str2): if (len(str1) > len(str2)): t = str1 str1 = str2 str2 = t str = "" n...
CodeGen-main
data/transcoder_evaluation_gfg/python/SUM_TWO_LARGE_NUMBERS.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( num , divisor ) : while ( num >= divisor ) : num -= divisor ; return num ; #TOFILL if __name__ =...
CodeGen-main
data/transcoder_evaluation_gfg/python/PROGRAM_TO_FIND_REMAINDER_WITHOUT_USING_MODULO_OR_OPERATOR_2.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( n ) : while ( int ( n / 100 ) ) : last_digit = int ( n % 10 ) n = int ( n / 10 ) n += l...
CodeGen-main
data/transcoder_evaluation_gfg/python/NUMBER_IS_DIVISIBLE_BY_29_OR_NOT.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( n ) : num = n ; dec_value = 0 ; base1 = 1 ; len1 = len ( num ) ; for i in range ( len1 - 1 , - ...
CodeGen-main
data/transcoder_evaluation_gfg/python/PROGRAM_BINARY_DECIMAL_CONVERSION_1.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( arr , n ) : found = False arr.sort ( ) for i in range ( 0 , n - 1 ) : l = i + 1 r = n -...
CodeGen-main
data/transcoder_evaluation_gfg/python/FIND_TRIPLETS_ARRAY_WHOSE_SUM_EQUAL_ZERO_2.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( arr , n ) : inc , dcr = dict ( ) , dict ( ) len_inc , len_dcr = [ 0 ] * n , [ 0 ] * n longLen = 0 f...
CodeGen-main
data/transcoder_evaluation_gfg/python/LENGTH_LONGEST_STRICT_BITONIC_SUBSEQUENCE.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( a , b ) : if ( a < 0 ) : a = - a if ( b < 0 ) : b = - b mod = a while ( mod >= b ) ...
CodeGen-main
data/transcoder_evaluation_gfg/python/MODULUS_TWO_FLOAT_DOUBLE_NUMBERS.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( str ) : n = len ( str ) ; return int ( n * ( n + 1 ) / 2 ) ; #TOFILL if __name__ == '__main__': para...
CodeGen-main
data/transcoder_evaluation_gfg/python/NUMBER_SUBSTRINGS_STRING.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( arr , l , r , x ) : if ( r >= l ) : mid = int ( l + ( r - l ) / 2 ) if ( arr [ mid ] == x ) : r...
CodeGen-main
data/transcoder_evaluation_gfg/python/SEARCH_ALMOST_SORTED_ARRAY.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( x ) : next = 0 if ( x ) : rightOne = x & - ( x ) nextHigherOneBit = x + int ( rightOne ) ...
CodeGen-main
data/transcoder_evaluation_gfg/python/NEXT_HIGHER_NUMBER_WITH_SAME_NUMBER_OF_SET_BITS.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # import sys def f_gold(arr, n, A, B, C): for i in range(n): arr[i] = (A * arr[i] * arr[i] + B * arr[i] + C) ind...
CodeGen-main
data/transcoder_evaluation_gfg/python/SORT_ARRAY_APPLYING_GIVEN_EQUATION.py
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( n ) : if n < 3 : return n elif n >= 3 and n < 10 : return n - 1 po = 1 while n / po...
CodeGen-main
data/transcoder_evaluation_gfg/python/COUNT_NUMBERS_THAT_DONT_CONTAIN_3.py