python_code stringlengths 0 992k | repo_name stringlengths 8 46 | file_path stringlengths 5 162 |
|---|---|---|
import pickle
import csv
import numpy as np
from rdkit import Chem
import torch
import torch.nn as nn
import torch.nn.functional as F
from transformers import BertModel, BertTokenizer
from utils import ToDevice
from utils.mol_utils import load_mol2vec
from models.base_models import MolEncoder, TextEncoder
class Tex... | OpenBioMed-main | open_biomed/models/multimodal/text2mol.py |
import logging
logger = logging.getLogger(__name__)
import torch
import torch.nn as nn
from transformers import BertModel
from models.base_models import MolEncoder, TextEncoder
class MolBERT(MolEncoder, TextEncoder):
def __init__(self, config):
super(MolBERT, self).__init__()
self.text_encoder ... | OpenBioMed-main | open_biomed/models/multimodal/bert.py |
import logging
logger = logging.getLogger(__name__)
import torch
import torch.nn as nn
from transformers import BertConfig, BertForPreTraining, BertModel
from models.base_models import MolEncoder, TextEncoder
class KVPLMStarEncoder(nn.Module):
def __init__(self, bert_config):
super(KVPLMStarEncoder, sel... | OpenBioMed-main | open_biomed/models/multimodal/kv_plm.py |
import torch
import torch.nn as nn
import torch.nn.functional as F
from transformers import BertConfig, BertModel
from models.base_models import MolEncoder, TextEncoder
from models.molecule.gnn_graphcl import GNNGraphCL
class MoMuTextEncoder(nn.Module):
def __init__(self, pretrained=True, model_name_or_path=None... | OpenBioMed-main | open_biomed/models/multimodal/momu.py |
import random
import torch
import torch.nn as nn
import torch.nn.functional as F
from models.base_models import MolEncoder, TextEncoder
from models.molecule.gnn_graphmvp import GNNGraphMVP
from models.multimodal.molfm.xbert import BertConfig, BertForMaskedLM
from models.knowledge.transe import TransE
from utils.mol_u... | OpenBioMed-main | open_biomed/models/multimodal/molfm/molfm.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... | OpenBioMed-main | open_biomed/models/multimodal/molfm/xbert.py |
import random
import torch
import torch.nn as nn
import torch.nn.functional as F
from transformers import RobertaConfig
from models.base_models import MolEncoder, TextEncoder
from models.molecule.unimap import UniMAP
from models.multimodal.molfm.xbert import BertConfig, BertForMaskedLM
from models.knowledge.transe imp... | OpenBioMed-main | open_biomed/models/multimodal/molfm/drugfm.py |
import logging
logger = logging.getLogger(__name__)
import contextlib
import torch
import torch.nn as nn
import re
import os
from transformers import LlamaTokenizer, EsmModel, EsmConfig
from models.base_models import MolEncoder, ProteinEncoder, TextEncoder
from models.molecule.gnn_graphmvp import GNNGraphMVP
from mo... | OpenBioMed-main | open_biomed/models/multimodal/biomedgpt/biomedgpt.py |
from models.multimodal.biomedgpt.biomedgpt_clip import BioMedGPTCLIP
from models.multimodal.biomedgpt.biomedgpt import BioMedGPTV | OpenBioMed-main | open_biomed/models/multimodal/biomedgpt/__init__.py |
import torch
import torch.nn as nn
import torch.nn.functional as F
from models.base_models import MolEncoder, TextEncoder
from models.molecule.gnn_graphcl import GNNGraphCL
from models.text.base_transformers import BaseTransformers
class BioMedGPTCLIP(MolEncoder, TextEncoder):
def __init__(self, config):
... | OpenBioMed-main | open_biomed/models/multimodal/biomedgpt/biomedgpt_clip.py |
# This script is based on https://github.com/huggingface/transformers/blob/main/src/transformers/models/llama/modeling_llama.py
""" PyTorch LLaMA model."""
import math
from typing import List, Optional, Tuple, Union
import torch
import torch.utils.checkpoint
from torch import nn
from torch.nn import BCEWithLogitsLoss... | OpenBioMed-main | open_biomed/models/multimodal/biomedgpt/modeling_llama.py |
from models.knowledge.transe import TransE
from models.knowledge.gin import GIN
| OpenBioMed-main | open_biomed/models/knowledge/__init__.py |
import math
import torch
import torch.nn as nn
from models.base_models import KnowledgeEncoder
class TransE(KnowledgeEncoder):
def __init__(self, n_ents, n_rels, norm=1, hidden_size=256, margin=1.0):
super().__init__()
self.n_ents = n_ents
self.n_rels = n_rels
self.norm = norm
... | OpenBioMed-main | open_biomed/models/knowledge/transe.py |
import torch
import math
import torch.nn as nn
import torch.nn.functional as F
import random
from torch_geometric.nn import GINConv, JumpingKnowledge
from models.base_models import KnowledgeEncoder
from models.protein.cnn import CNNGRU
SUPPORTED_FEATURE_NETWORK = {
"cnn_gru": CNNGRU,
"linear": lambda x: nn.L... | OpenBioMed-main | open_biomed/models/knowledge/gin.py |
from models.text.base_transformers import BaseTransformers
| OpenBioMed-main | open_biomed/models/text/__init__.py |
import torch
import torch.nn as nn
from transformers import AutoModel, AutoConfig
from models.base_models import TextEncoder
class BaseTransformers(TextEncoder):
def __init__(self, config):
super(BaseTransformers, self).__init__()
transformer_config = AutoConfig.from_pretrained(config["model_name... | OpenBioMed-main | open_biomed/models/text/base_transformers.py |
import torch
from torch import nn
import torch.nn.functional as F
from torch_geometric.nn import MessagePassing
from torch_geometric.utils import add_self_loops
from torch_geometric.nn import global_add_pool, global_mean_pool, global_max_pool
from models.base_models import MolEncoder
num_atom_type = 119 # including ... | OpenBioMed-main | open_biomed/models/molecule/gnn_molclr.py |
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch_geometric.nn import GINConv, JumpingKnowledge, global_max_pool
from models.base_models import MolEncoder
class GINTGSA(MolEncoder):
def __init__(self, layer_drug, dim_drug):
super().__init__()
self.layer_drug = layer_dru... | OpenBioMed-main | open_biomed/models/molecule/gin_tgsa.py |
from models.molecule.cnn import MolCNN
from models.molecule.gin_tgsa import GINTGSA
from models.molecule.gnn_graphcl import GraphCL
from models.molecule.gnn_graphmvp import GraphMVP
from models.molecule.gnn_molclr import MolCLR
from models.molecule.mgnn import MGNN
from models.molecule.unimap import UniMAP
from models.... | OpenBioMed-main | open_biomed/models/molecule/__init__.py |
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
from models.base_models import MolEncoder
class MolCNN(MolEncoder):
def __init__(self, config):
super(MolCNN, self).__init__()
self.output_dim = config["output_dim"]
layer_size =... | OpenBioMed-main | open_biomed/models/molecule/cnn.py |
import logging
logger = logging.getLogger(__name__)
import os
import numpy as np
import re
import math
from rdkit import Chem
import json
from scipy import linalg as la
import torch
import torch.nn as nn
import torch.nn.functional as F
atom_decoder_m = {0: 6, 1: 7, 2: 8, 3: 9}
bond_decoder_m = {1: Chem.rdchem.BondT... | OpenBioMed-main | open_biomed/models/molecule/moflow.py |
import logging
logger = logging.getLogger(__name__)
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch_geometric.nn import (MessagePassing, global_add_pool, global_max_pool, global_mean_pool)
from torch_geometric.nn.inits import glorot, zeros
from torch_geometric.utils import add_self_loops,... | OpenBioMed-main | open_biomed/models/molecule/gnn_graphmvp.py |
'''
Implementation of MGNN in MGraphDTA: Deep Multiscale Graph Neural Network for Explainable Drug-target binding affinity Prediction
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn.modules.batchnorm import _BatchNorm
import torch_geometric.nn as gnn
from torch import Tensor
from c... | OpenBioMed-main | open_biomed/models/molecule/mgnn.py |
import torch
import torch.nn as nn
from torch_geometric.nn import MessagePassing
from torch_geometric.utils import add_self_loops, degree, softmax
from torch_geometric.nn import global_add_pool, global_mean_pool, global_max_pool, GlobalAttention, Set2Set
import torch.nn.functional as F
from torch_scatter import scatter... | OpenBioMed-main | open_biomed/models/molecule/gnn_graphcl.py |
from typing import Optional, Callable
import torch
import torch.nn.functional as F
from torch.nn.modules.sparse import Embedding
from torch_geometric.nn import MessagePassing
from torch_scatter import scatter
from torch import nn, Tensor
# from fairseq import utils
from torch_geometric.nn import global_max_pool, global... | OpenBioMed-main | open_biomed/models/molecule/unimap/gcn.py |
import os
import sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))))
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.distributed as dist
import copy
import transformers
from transformers import RobertaTokenizer
from transfo... | OpenBioMed-main | open_biomed/models/molecule/unimap/unimap.py |
from models.molecule.unimap.unimap import UniMAP | OpenBioMed-main | open_biomed/models/molecule/unimap/__init__.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... | OpenBioMed-main | open_biomed/models/molecule/unimap/modeling_roberta.py |
OpenBioMed-main | open_biomed/feature/__init__.py | |
from abc import ABC, abstractmethod
from transformers import BertModel, BertTokenizer, T5Model, T5Tokenizer, GPT2Model, GPT2Tokenizer
from feature.base_featurizer import BaseFeaturizer
from utils import ToDevice
# Warning: it seems that the results of AutoTokenizer and specified tokenizer is different
name2tokenizer ... | OpenBioMed-main | open_biomed/feature/text_featurizer.py |
import logging
logger = logging.getLogger(__name__)
import os
import sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import argparse
import copy
import json
import numpy as np
import pickle
import torch
import rdkit.Chem as Chem
from rdkit.Chem import DataStructs, rdmolops
from rdk... | OpenBioMed-main | open_biomed/feature/mol_featurizer.py |
from abc import ABC, abstractmethod
class BaseFeaturizer(ABC):
def __init__(self):
super(BaseFeaturizer, self).__init__()
@abstractmethod
def __call__(self, data):
raise NotImplementedError | OpenBioMed-main | open_biomed/feature/base_featurizer.py |
from abc import ABC, abstractmethod
import torch
from feature.base_featurizer import BaseFeaturizer
from utils.kg_utils import SUPPORTED_KG, embed
class KGFeaturizer(BaseFeaturizer, ABC):
def __init__(self, config):
super().__init__()
self.config = config
# TODO:self.kg is no use
... | OpenBioMed-main | open_biomed/feature/kg_featurizer.py |
import copy
import numpy as np
from sklearn.preprocessing import OneHotEncoder
import torch
from feature.base_featurizer import BaseFeaturizer
from feature.kg_featurizer import SUPPORTED_KG_FEATURIZER
from feature.text_featurizer import SUPPORTED_TEXT_FEATURIZER
from utils import ToDevice
from transformers import Au... | OpenBioMed-main | open_biomed/feature/protein_featurizer.py |
import logging
logger = logging.getLogger(__name__)
import os
import pickle
import torch
import numpy as np
from torch_geometric.data import Data, Batch
from torch_geometric.nn import graclus, max_pool
from feature.base_featurizer import BaseFeaturizer
from utils.kg_utils import STRING
class CellTGSAFeaturizer(Base... | OpenBioMed-main | open_biomed/feature/cell_featurizer.py |
from pathlib import Path
from setuptools import find_packages, setup
if __name__ == "__main__":
with Path(Path(__file__).parent, "README.md").open(encoding="utf-8") as file:
long_description = file.read()
# TODO: This is a hack to get around the fact that we can't read the requirements.txt file, we s... | flamingo-main | setup.py |
from .src.flamingo import Flamingo
from .src.factory import create_model_and_transforms
| flamingo-main | open_flamingo/__init__.py |
import time
from contextlib import suppress
import torch
from tqdm import tqdm
def get_cast_dtype(precision: str):
cast_dtype = None
if precision == "bf16":
cast_dtype = torch.bfloat16
elif precision == "fp16":
cast_dtype = torch.float16
return cast_dtype
def get_autocast(precision)... | flamingo-main | open_flamingo/train/train_utils.py |
flamingo-main | open_flamingo/train/__init__.py | |
import os
import torch
try:
import horovod.torch as hvd
except ImportError:
hvd = None
def is_global_master(args):
return args.rank == 0
def is_local_master(args):
return args.local_rank == 0
def is_master(args, local=False):
return is_local_master(args) if local else is_global_master(args)
... | flamingo-main | open_flamingo/train/distributed.py |
""" Main training script """
import argparse
import copy
import glob
import os
import random
import numpy as np
import torch
import wandb
from data import get_data
from distributed import init_distributed_device, world_info_from_env
from torch.nn.parallel import DistributedDataParallel as DDP
from train_utils import ... | flamingo-main | open_flamingo/train/train.py |
import ast
import functools
import io
import json
import logging
import math
import os
import random
import sys
import tarfile
from dataclasses import dataclass
from multiprocessing import Value
import braceexpand
import torch
import torchvision
import webdataset as wds
from PIL import Image
from torch.utils.data impo... | flamingo-main | open_flamingo/train/data.py |
from typing import Dict, Sequence, Tuple
import re
import numpy as np
import torch
def postprocess_classification_generation(predictions) -> str:
return re.split("Prompt|Completion", predictions, 1)[0]
def compute_classification_accuracy(predictions: Sequence[Dict[str, str]]) -> float:
"""Compute the accura... | flamingo-main | open_flamingo/eval/classification.py |
# Those are manual mapping that are not caught by our stemming rules or would
# would be done incorrectly by our automatic stemming rule. In details,
# the keys of the _MANUAL_MATCHES dict contains the original word and the value
# contains the transformation of the word expected by the OKVQA stemming rule.
# These man... | flamingo-main | open_flamingo/eval/ok_vqa_utils.py |
# classnames via https://github.com/mlfoundations/wise-ft/blob/master/src/datasets/imagenet_classnames.py#L1
openai_imagenet_classnames = [
"tench",
"goldfish",
"great white shark",
"tiger shark",
"hammerhead shark",
"electric ray",
"stingray",
"rooster",
"hen",
"ostrich",
"b... | flamingo-main | open_flamingo/eval/imagenet_utils.py |
flamingo-main | open_flamingo/eval/__init__.py | |
import argparse
import json
from math import ceil
import os
import random
import uuid
from collections import defaultdict
from typing import Callable
import more_itertools
import numpy as np
import torch
from coco_metric import compute_cider, postprocess_captioning_generation
from eval_datasets import COCOFlickrDatase... | flamingo-main | open_flamingo/eval/evaluate.py |
from pycocoevalcap.eval import COCOEvalCap
from pycocotools.coco import COCO
def compute_cider(
result_path,
annotations_path="/data/yfcc-tmp/data/mscoco/annotations/captions_train2017.json",
):
# create coco object and coco_result object
coco = COCO(annotations_path)
coco_result = coco.loadRes(re... | flamingo-main | open_flamingo/eval/coco_metric.py |
import json
import os
from PIL import Image
from torch.utils.data import Dataset
from torchvision.datasets import ImageFolder
from open_flamingo.eval.imagenet_utils import IMAGENET_1K_CLASS_ID_TO_LABEL
class COCOFlickrDataset(Dataset):
def __init__(
self,
image_dir_path="/mmfs1/gscratch/efml/ana... | flamingo-main | open_flamingo/eval/eval_datasets.py |
import copy
import datetime
import json
import os
import random
import re
import sys
# Interface for accessing the VQA dataset.
# This code is based on the code written by Tsung-Yi Lin for MSCOCO Python API available at the following link:
# (https://github.com/pdollar/coco/blob/master/PythonAPI/pycocotools/coco.py).... | flamingo-main | open_flamingo/eval/vqa_metric.py |
flamingo-main | open_flamingo/src/__init__.py | |
from transformers import AutoModelForCausalLM, AutoTokenizer
import open_clip
from .flamingo import Flamingo
from .flamingo_lm import FlamingoLMMixin
from .utils import extend_instance
def create_model_and_transforms(
clip_vision_encoder_path: str,
clip_vision_encoder_pretrained: str,
lang_encoder_path: ... | flamingo-main | open_flamingo/src/factory.py |
import random
import torch.nn as nn
from .helpers import GatedCrossAttentionBlock
from .utils import getattr_recursive, setattr_recursive
class FlamingoLayer(nn.Module):
def __init__(self, gated_cross_attn_layer, decoder_layer):
super().__init__()
self.gated_cross_attn_layer = gated_cross_attn_l... | flamingo-main | open_flamingo/src/flamingo_lm.py |
import torch
from einops import rearrange
from torch import nn
from .helpers import PerceiverResampler
class Flamingo(nn.Module):
def __init__(
self,
vision_encoder: nn.Module,
lang_encoder: nn.Module,
eoc_token_id: int,
media_token_id: int,
vis_dim: int,
c... | flamingo-main | open_flamingo/src/flamingo.py |
def extend_instance(obj, mixin):
"""Apply mixins to a class instance after creation"""
base_cls = obj.__class__
base_cls_name = obj.__class__.__name__
obj.__class__ = type(
base_cls_name, (mixin, base_cls), {}
) # mixin needs to go first for our forward() logic to work
def getattr_recursi... | flamingo-main | open_flamingo/src/utils.py |
"""
Taken from https://github.com/lucidrains/flamingo-pytorch
"""
import torch
from einops import rearrange, repeat
from einops_exts import rearrange_many
from torch import einsum, nn
def exists(val):
return val is not None
def FeedForward(dim, mult=4):
inner_dim = int(dim * mult)
return nn.Sequential(... | flamingo-main | open_flamingo/src/helpers.py |
# import unittest
# import requests
# from PIL import Image
# from open_flamingo import create_model_and_transforms
# class TestFlamingoModel(unittest.TestCase):
# def test_forward_pass(self):
# model, image_processor, tokenizer = create_model_and_transforms(
# clip_vision_encoder_path="hf-i... | flamingo-main | tests/test_flamingo_model.py |
from setuptools import setup, find_packages
setup(
name = 'primus',
packages = find_packages(exclude=[]),
version = '0.0.2',
license='MIT',
description = 'cybertron- Pytorch',
author = 'Kye Gomez',
author_email = 'kye@apac.ai',
long_description_content_type = 'text/markdown',
url = 'https://github.co... | CyberTron-master | setup.py |
#builds dataset automatically => adds to your hf account
import multiprocessing
import argparse
from itertools import chain
from datasets import load_dataset
from transformers import AutoTokenizer
class CFG:
SEED: int = 42
SEQ_LEN: int = 8192 # context length make it larger or smaller depending on your task
... | CyberTron-master | build_dataset.py |
CyberTron-master | cybertron/models/__init__.py | |
from collections import namedtuple
from functools import wraps
from packaging import version
import torch
from torch import nn, einsum
import torch.nn.functional as F
from einops import rearrange
# constants
EfficientAttentionConfig = namedtuple('EfficientAttentionConfig', ['enable_flash', 'enable_math', 'enable_me... | CyberTron-master | cybertron/models/rt1/flash_attn.py |
import torch
import torch.nn.functional as F
from torch import nn, einsum, Tensor
from typing import List, Optional, Callable, Tuple
from beartype import beartype
from einops import pack, unpack, repeat, reduce, rearrange
from einops.layers.torch import Rearrange, Reduce
from classifier_free_guidance_pytorch import... | CyberTron-master | cybertron/models/rt1/robotic_transformer.py |
#builds dataset automatically => adds to your hf account
import multiprocessing
import argparse
from itertools import chain
from datasets import load_dataset
from transformers import AutoTokenizer
class CFG:
SEED: int = 42
SEQ_LEN: int = 8192 # context length make it larger or smaller depending on your task
... | CyberTron-master | cybertron/models/rt1/tokenize_dataset.py |
import torch
from robotic_transformer import MaxViT, RT1
vit = MaxViT(
num_classes = 1000,
dim_conv_stem = 64,
dim = 96,
dim_head = 36,
depth = (2, 2, 5, 2),
window_size = 7,
mb_conv_expansion_rate = 4,
mbconv_shrinkage_rate = 0.25,
dropout = 0.1
)
model = RT1(
vit = vit,
... | CyberTron-master | cybertron/models/rt1/model.py |
import math
import multiprocessing
import os
from datetime import timedelta
from functools import partial
from itertools import chain
import torch
from torch.distributed.fsdp import (
FullyShardedDataParallel,
MixedPrecision,
BackwardPrefetch,
ShardingStrategy,
)
from accelerate import Accelerator
from... | CyberTron-master | cybertron/models/rt1/train.py |
import torch
# This is the unfused version of StableAdamW. It is slower than the fused version (coming).
class StableAdamWUnfused(torch.optim.Optimizer):
def __init__(
self,
params,
lr=0.002,
weight_decay=0.2,
betas=(0.9, 0.99),
eps=1e-8,
clip_thresh=1.0,
... | CyberTron-master | cybertron/models/rt1/utils/stable_adam.py |
from setuptools import find_packages, setup
setup(
name='gato',
version='0.0.1',
description='Gato: A Generalist Agent',
url='https://github.com/kyegomez/GATO',
author='Kye Gomez',
author_email='kye@apac.ai',
long_description=open('README.md', 'r', encoding='utf-8').read(),
long_descrip... | CyberTron-master | cybertron/models/GATO/setup.py |
import torch
from gato import Gato, GatoConfig
# Create model instance
config = GatoConfig.small()
gato = Gato(config)
# Fake inputs for Gato
input_dim = config.input_dim
input_ids = torch.cat([
torch.rand((1, 1, input_dim)) for _ in range(20)] + # 20 image patches
[torch.full((1, 1, input_dim), 0.25), # co... | CyberTron-master | cybertron/models/GATO/example.py |
import math
import multiprocessing
import os
from datetime import timedelta
from functools import partial
from itertools import chain
import torch
from torch.distributed.fsdp import (
FullyShardedDataParallel,
MixedPrecision,
BackwardPrefetch,
ShardingStrategy,
)
from accelerate import Accelerator
from... | CyberTron-master | cybertron/models/GATO/training.py |
import copy
from typing import Dict, Any
class GatoConfig:
@staticmethod
def large():
return GatoConfig(num_transformer_blocks=24,
num_attention_heads=16,
layer_width=2048,
feedforward_hidden_size=8192,
... | CyberTron-master | cybertron/models/GATO/gato/config.py |
from flowchain import enable_tensor_chaining
enable_tensor_chaining()
| CyberTron-master | cybertron/models/GATO/gato/__init__.py |
from typing import Dict, Any, Union
from gato import GatoConfig
import torch
import torch.nn as nn
import torch.nn.functional as F
from gato import GatoConfig
def _randomized_positions(from_v, to_v):
pos = torch.rand_like(from_v) * (to_v - from_v)
return pos.int()
def _rounded_mean_positions(from_v, to_v... | CyberTron-master | cybertron/models/GATO/gato/models/embedding.py |
from gato.models.transformer import TransformerBlock
from gato.models.embedding import PatchPositionEncoding, ResidualEmbedding, LocalPositionEncoding, DiscreteEmbedding
from gato.models.tokenizers import ContinousValueTokenizer
from gato import GatoConfig
import torch
import torch.nn as nn
import torch.nn.functio... | CyberTron-master | cybertron/models/GATO/gato/models/__init__.py |
from gato import GatoConfig
import torch.nn as nn
#implement alibi, flash sparse multihead attention + other juicy plug methods
from flash_attn.flash_blocksparse_attention import FlashBlocksparseMHA
class TransformerBlock(nn.Module):
def __init__(self, config):
super(TransformerBlock, self).__init__()
... | CyberTron-master | cybertron/models/GATO/gato/models/transformer.py |
from gato import GatoConfig
import torch
import torch.nn as nn
def mu_law_encode(x, mu=100, m=256):
numerator = torch.log(x.abs(), * mu + 1.0)
denominator = torch.log(m * mu + 1.0)
return (numerator / denominator) * x.sign()
def tokenize_continous_value(x, mu=100, m=256, bins=1024, shift=None):
#app... | CyberTron-master | cybertron/models/GATO/gato/models/tokenizers.py |
from ray.rllib.algorithms.impala import ImpalaConfig
from ray.tune.logger import pretty_print
import datetime
import os
import tempfile
from ray.tune.logger.unified import UnifiedLogger # noqa: E402
def custom_log_creator(custom_path, custom_str):
timestr = datetime.datetime.today().strftime("%Y-%m-%d_%H-%M-%... | CyberTron-master | cybertron/models/GATO/datasets/control_env/ALE_Atari/atari_test_impala.py |
# Copyright 2022 Google LLC
#
# 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 agreed to in writing, ... | CyberTron-master | cybertron/models/robotics_transformer/transformer_test.py |
# Copyright 2022 Google LLC
#
# 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 agreed to in writing, ... | CyberTron-master | cybertron/models/robotics_transformer/sequence_agent.py |
# Copyright 2022 Google LLC
#
# 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 agreed to in writing, ... | CyberTron-master | cybertron/models/robotics_transformer/sequence_agent_test_set_up.py |
# Copyright 2022 Google LLC
#
# 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 agreed to in writing, ... | CyberTron-master | cybertron/models/robotics_transformer/transformer_network_test_set_up.py |
# Copyright 2022 Google LLC
#
# 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 agreed to in writing, ... | CyberTron-master | cybertron/models/robotics_transformer/__init__.py |
# Copyright 2022 Google LLC
#
# 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 agreed to in writing, ... | CyberTron-master | cybertron/models/robotics_transformer/transformer_network_test.py |
# Copyright 2022 Google LLC
#
# 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 agreed to in writing, ... | CyberTron-master | cybertron/models/robotics_transformer/transformer.py |
# Copyright 2022 Google LLC
#
# 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 agreed to in writing, ... | CyberTron-master | cybertron/models/robotics_transformer/sequence_agent_test.py |
# Copyright 2022 Google LLC
#
# 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 agreed to in writing, ... | CyberTron-master | cybertron/models/robotics_transformer/transformer_network.py |
# Copyright 2022 Google LLC
#
# 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 agreed to in writing, ... | CyberTron-master | cybertron/models/robotics_transformer/tokenizers/token_learner_test.py |
# Copyright 2022 Google LLC
#
# 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 agreed to in writing, ... | CyberTron-master | cybertron/models/robotics_transformer/tokenizers/action_tokenizer.py |
# Copyright 2022 Google LLC
#
# 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 agreed to in writing, ... | CyberTron-master | cybertron/models/robotics_transformer/tokenizers/token_learner.py |
# Copyright 2022 Google LLC
#
# 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 agreed to in writing, ... | CyberTron-master | cybertron/models/robotics_transformer/tokenizers/__init__.py |
# Copyright 2022 Google LLC
#
# 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 agreed to in writing, ... | CyberTron-master | cybertron/models/robotics_transformer/tokenizers/action_tokenizer_test.py |
# Copyright 2022 Google LLC
#
# 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 agreed to in writing, ... | CyberTron-master | cybertron/models/robotics_transformer/tokenizers/image_tokenizer_test.py |
# Copyright 2022 Google LLC
#
# 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 agreed to in writing, ... | CyberTron-master | cybertron/models/robotics_transformer/tokenizers/image_tokenizer.py |
# Copyright 2022 Google LLC
#
# 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 agreed to in writing, ... | CyberTron-master | cybertron/models/robotics_transformer/film_efficientnet/pretrained_efficientnet_encoder.py |
# Copyright 2022 Google LLC
#
# 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 agreed to in writing, ... | CyberTron-master | cybertron/models/robotics_transformer/film_efficientnet/pretrained_efficientnet_encoder_test.py |
# Copyright 2022 Google LLC
#
# 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 agreed to in writing, ... | CyberTron-master | cybertron/models/robotics_transformer/film_efficientnet/film_efficientnet_encoder_test.py |
# Copyright 2022 Google LLC
#
# 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 agreed to in writing, ... | CyberTron-master | cybertron/models/robotics_transformer/film_efficientnet/film_conditioning_layer_test.py |
# Copyright 2022 Google LLC
#
# 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 agreed to in writing, ... | CyberTron-master | cybertron/models/robotics_transformer/film_efficientnet/__init__.py |
# Copyright 2022 Google LLC
#
# 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 agreed to in writing, ... | CyberTron-master | cybertron/models/robotics_transformer/film_efficientnet/film_conditioning_layer.py |
# Copyright 2022 Google LLC
#
# 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 agreed to in writing, ... | CyberTron-master | cybertron/models/robotics_transformer/film_efficientnet/preprocessors.py |
# Copyright 2022 Google LLC
#
# 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 agreed to in writing, ... | CyberTron-master | cybertron/models/robotics_transformer/film_efficientnet/preprocessors_test.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.