repo stringlengths 2 99 | file stringlengths 13 225 | code stringlengths 0 18.3M | file_length int64 0 18.3M | avg_line_length float64 0 1.36M | max_line_length int64 0 4.26M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
adcgan | adcgan-main/BigGAN-PyTorch/inception_tf13.py | ''' Tensorflow inception score code
Derived from https://github.com/openai/improved-gan
Code derived from tensorflow/tensorflow/models/image/imagenet/classify_image.py
THIS CODE REQUIRES TENSORFLOW 1.3 or EARLIER to run in PARALLEL BATCH MODE
To use this code, run sample.py on your model with --sample_npz, and then
... | 5,363 | 37.869565 | 191 | py |
adcgan | adcgan-main/BigGAN-PyTorch/train_fns.py | ''' train_fns.py
Functions for the main loop of training different conditional image models
'''
import torch
import torch.nn as nn
import torchvision
import os
import utils
import losses
# Dummy training function for debugging
def dummy_training_function():
def train(x, y):
return {}
return train
def GAN_t... | 11,139 | 47.017241 | 181 | py |
adcgan | adcgan-main/BigGAN-PyTorch/BigGAN.py | import numpy as np
import math
import functools
import torch
import torch.nn as nn
from torch.nn import init
import torch.optim as optim
import torch.nn.functional as F
from torch.nn import Parameter as P
import layers
from sync_batchnorm import SynchronizedBatchNorm2d as SyncBatchNorm2d
# Architectures for G
# Att... | 20,469 | 43.307359 | 267 | py |
adcgan | adcgan-main/BigGAN-PyTorch/utils.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
''' Utilities file
This file contains utility functions for bookkeeping, logging, and data loading.
Methods which directly affect training should either go in layers, the model,
or train_fns.py.
'''
from __future__ import print_function
import sys
import os
import numpy a... | 49,789 | 39.878489 | 109 | py |
adcgan | adcgan-main/BigGAN-PyTorch/layers.py | ''' Layers
This file contains various layers for the BigGAN models.
'''
import numpy as np
import torch
import torch.nn as nn
from torch.nn import init
import torch.optim as optim
import torch.nn.functional as F
from torch.nn import Parameter as P
from sync_batchnorm import SynchronizedBatchNorm2d as SyncBN2d
# ... | 17,130 | 36.32244 | 101 | py |
adcgan | adcgan-main/BigGAN-PyTorch/datasets.py | ''' Datasets
This file contains definitions for our CIFAR, ImageFolder, and HDF5 datasets
'''
import os
import os.path
import sys
from PIL import Image
import numpy as np
from tqdm import tqdm, trange
import torchvision.datasets as dset
import torchvision.transforms as transforms
from torchvision.datasets.utils im... | 11,416 | 30.451791 | 139 | py |
adcgan | adcgan-main/BigGAN-PyTorch/inception_utils.py | ''' Inception utilities
This file contains methods for calculating IS and FID, using either
the original numpy code or an accelerated fully-pytorch version that
uses a fast newton-schulz approximation for the matrix sqrt. There are also
methods for acquiring a desired number of samples from the Generat... | 12,572 | 38.662461 | 136 | py |
adcgan | adcgan-main/BigGAN-PyTorch/animal_hash.py | c = ['Aardvark', 'Abyssinian', 'Affenpinscher', 'Akbash', 'Akita', 'Albatross',
'Alligator', 'Alpaca', 'Angelfish', 'Ant', 'Anteater', 'Antelope', 'Ape',
'Armadillo', 'Ass', 'Avocet', 'Axolotl', 'Baboon', 'Badger', 'Balinese',
'Bandicoot', 'Barb', 'Barnacle', 'Barracuda', 'Bat', 'Beagle', 'Bear',
'B... | 32,285 | 72.544419 | 82 | py |
adcgan | adcgan-main/BigGAN-PyTorch/calculate_inception_moments.py | ''' Calculate Inception Moments
This script iterates over the dataset and calculates the moments of the
activations of the Inception net (needed for FID), and also returns
the Inception Score of the training data.
Note that if you don't shuffle the data, the IS of true data will be under-
estimated as it is lab... | 5,247 | 40 | 122 | py |
adcgan | adcgan-main/BigGAN-PyTorch/train.py | """ BigGAN: The Authorized Unofficial PyTorch release
Code by A. Brock and A. Andonian
This code is an unofficial reimplementation of
"Large-Scale GAN Training for High Fidelity Natural Image Synthesis,"
by A. Brock, J. Donahue, and K. Simonyan (arXiv 1809.11096).
Let's go.
"""
import os
import fu... | 9,268 | 39.475983 | 124 | py |
adcgan | adcgan-main/BigGAN-PyTorch/sync_batchnorm/replicate.py | # -*- coding: utf-8 -*-
# File : replicate.py
# Author : Jiayuan Mao
# Email : maojiayuan@gmail.com
# Date : 27/01/2018
#
# This file is part of Synchronized-BatchNorm-PyTorch.
# https://github.com/vacancy/Synchronized-BatchNorm-PyTorch
# Distributed under MIT License.
import functools
from torch.nn.parallel.da... | 3,226 | 32.968421 | 115 | py |
adcgan | adcgan-main/BigGAN-PyTorch/sync_batchnorm/unittest.py | # -*- coding: utf-8 -*-
# File : unittest.py
# Author : Jiayuan Mao
# Email : maojiayuan@gmail.com
# Date : 27/01/2018
#
# This file is part of Synchronized-BatchNorm-PyTorch.
# https://github.com/vacancy/Synchronized-BatchNorm-PyTorch
# Distributed under MIT License.
import unittest
import torch
class TorchTes... | 746 | 23.9 | 59 | py |
adcgan | adcgan-main/BigGAN-PyTorch/sync_batchnorm/batchnorm.py | # -*- coding: utf-8 -*-
# File : batchnorm.py
# Author : Jiayuan Mao
# Email : maojiayuan@gmail.com
# Date : 27/01/2018
#
# This file is part of Synchronized-BatchNorm-PyTorch.
# https://github.com/vacancy/Synchronized-BatchNorm-PyTorch
# Distributed under MIT License.
import collections
import torch
import torc... | 14,882 | 41.644699 | 159 | py |
adcgan | adcgan-main/BigGAN-PyTorch/sync_batchnorm/batchnorm_reimpl.py | #! /usr/bin/env python3
# -*- coding: utf-8 -*-
# File : batchnorm_reimpl.py
# Author : acgtyrant
# Date : 11/01/2018
#
# This file is part of Synchronized-BatchNorm-PyTorch.
# https://github.com/vacancy/Synchronized-BatchNorm-PyTorch
# Distributed under MIT License.
import torch
import torch.nn as nn
import torch... | 2,383 | 30.786667 | 95 | py |
adcgan | adcgan-main/BigGAN-PyTorch/sync_batchnorm/comm.py | # -*- coding: utf-8 -*-
# File : comm.py
# Author : Jiayuan Mao
# Email : maojiayuan@gmail.com
# Date : 27/01/2018
#
# This file is part of Synchronized-BatchNorm-PyTorch.
# https://github.com/vacancy/Synchronized-BatchNorm-PyTorch
# Distributed under MIT License.
import queue
import collections
import threading... | 4,449 | 31.246377 | 117 | py |
adcgan | adcgan-main/BigGAN-PyTorch/sync_batchnorm/__init__.py | # -*- coding: utf-8 -*-
# File : __init__.py
# Author : Jiayuan Mao
# Email : maojiayuan@gmail.com
# Date : 27/01/2018
#
# This file is part of Synchronized-BatchNorm-PyTorch.
# https://github.com/vacancy/Synchronized-BatchNorm-PyTorch
# Distributed under MIT License.
from .batchnorm import SynchronizedBatchNorm... | 449 | 33.615385 | 96 | py |
adcgan | adcgan-main/BigGAN-PyTorch/TFHub/biggan_v1.py | # BigGAN V1:
# This is now deprecated code used for porting the TFHub modules to pytorch,
# included here for reference only.
import numpy as np
import torch
from scipy.stats import truncnorm
from torch import nn
from torch.nn import Parameter
from torch.nn import functional as F
def l2normalize(v, eps=1e-4):
retur... | 12,173 | 30.29563 | 114 | py |
adcgan | adcgan-main/BigGAN-PyTorch/TFHub/converter.py | """Utilities for converting TFHub BigGAN generator weights to PyTorch.
Recommended usage:
To convert all BigGAN variants and generate test samples, use:
```bash
CUDA_VISIBLE_DEVICES=0 python converter.py --generate_samples
```
See `parse_args` for additional options.
"""
import argparse
import os
import sys
impor... | 17,428 | 42.355721 | 143 | py |
DeepSpectrum | DeepSpectrum-master/setup.py | #!/usr/bin/env python
import re
import sys
import warnings
warnings.filterwarnings('ignore', category=DeprecationWarning)
warnings.filterwarnings('ignore', category=FutureWarning)
from setuptools import setup, find_packages
from subprocess import CalledProcessError, check_output
PROJECT = "DeepSpectrum"
VERSION = "0.... | 2,795 | 29.064516 | 150 | py |
DeepSpectrum | DeepSpectrum-master/src/deepspectrum/__main__.py | import sys, os
# sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'auDeep'))
import warnings
# from numba.errors import NumbaDeprecationWarning, NumbaPendingDeprecationWarning
warnings.filterwarnings('ignore', category=DeprecationWarning)
warnings.filterwarnings('ignore', category=FutureWarning)
# w... | 2,397 | 32.305556 | 119 | py |
DeepSpectrum | DeepSpectrum-master/src/deepspectrum/__init__.py | import logging
import sys
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
__version__ = '0.6.9'
| 108 | 17.166667 | 58 | py |
DeepSpectrum | DeepSpectrum-master/src/deepspectrum/cli/features.py | import logging
import click
from deepspectrum.cli.configuration import Configuration, GENERAL_OPTIONS,\
PLOTTING_OPTIONS, EXTRACTION_OPTIONS, LABEL_OPTIONS, WRITER_OPTIONS, Filetypes
from os import environ
from .utils import add_options
log = logging.getLogger(__name__)
DESCRIPTION_EXTRACT = 'Extract deep spectrum fe... | 1,569 | 34.681818 | 78 | py |
DeepSpectrum | DeepSpectrum-master/src/deepspectrum/cli/utils.py | def add_options(options):
def _add_options(func):
for option in reversed(options):
func = option(func)
return func
return _add_options
| 172 | 20.625 | 40 | py |
DeepSpectrum | DeepSpectrum-master/src/deepspectrum/cli/configuration.py | import logging
import click
import configparser
import fnmatch
import re
import decimal
from enum import Enum
from multiprocessing import cpu_count
from os import makedirs, walk
from matplotlib import cm
from os.path import abspath, join, isfile, basename, dirname, realpath, splitext
mpl_cmaps = list(cm.cmaps_listed)+... | 18,723 | 34.732824 | 194 | py |
DeepSpectrum | DeepSpectrum-master/src/deepspectrum/cli/plot.py | import click
import logging
from os import environ
from tqdm import tqdm
from deepspectrum.cli.configuration import Configuration, GENERAL_OPTIONS, PLOTTING_OPTIONS
from .utils import add_options
from ..backend.plotting import PlotGenerator
environ['GLOG_minloglevel'] = '2'
environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
log =... | 1,284 | 30.341463 | 91 | py |
DeepSpectrum | DeepSpectrum-master/src/deepspectrum/cli/__init__.py | 0 | 0 | 0 | py | |
DeepSpectrum | DeepSpectrum-master/src/deepspectrum/cli/features_with_parser.py | from os import environ
from .utils import add_options
import logging
import click
from deepspectrum.cli.configuration import Configuration, GENERAL_OPTIONS, PLOTTING_OPTIONS, EXTRACTION_OPTIONS, PARSER_OPTIONS, WRITER_OPTIONS, Filetypes
log = logging.getLogger(__name__)
DESCRIPTION_EXTRACT = 'Extract deep spectrum f... | 7,436 | 41.255682 | 154 | py |
DeepSpectrum | DeepSpectrum-master/src/deepspectrum/cli/image_features.py | import numpy as np
import click
import logging
from os import environ
from os.path import basename
from .configuration import Configuration, GENERAL_OPTIONS, EXTRACTION_OPTIONS, LABEL_OPTIONS, WRITER_OPTIONS, Filetypes
from .utils import add_options
from ..backend.plotting import PlotTuple
from ..tools.path import get_... | 1,778 | 33.882353 | 119 | py |
DeepSpectrum | DeepSpectrum-master/src/deepspectrum/tools/feature_writer.py | import csv
from tqdm import tqdm
from .custom_arff import ArffWriter
import logging
log = logging.getLogger(__name__)
class FeatureWriter:
def __init__(self, output, label_dict, labels, continuous_labels,
write_timestamps, no_labels):
self.output = output
self.label_dict = lab... | 5,622 | 40.043796 | 91 | py |
DeepSpectrum | DeepSpectrum-master/src/deepspectrum/tools/custom_arff.py | import logging
log = logging.getLogger(__name__)
class ArffWriter():
def __init__(self, file_object, relation_name, attributes):
self.arff_file = file_object
self.relation_name = relation_name
self.attributes = attributes
self._write_header()
def _write_header(self):
... | 808 | 30.115385 | 74 | py |
DeepSpectrum | DeepSpectrum-master/src/deepspectrum/tools/label_parser.py | import csv
import decimal
from os.path import splitext, normpath
class LabelParser():
def __init__(self,
filepath,
delimiter=',',
timecontinuous=False,
remove_extension=False):
self._timecontinuous = timecontinuous
self._filepath ... | 2,102 | 32.919355 | 102 | py |
DeepSpectrum | DeepSpectrum-master/src/deepspectrum/tools/path.py | import pathlib
from os.path import basename
def get_relative_path(path, prefix):
filepath = pathlib.PurePath(path)
if prefix is None:
return basename(filepath)
else:
filepath = filepath.relative_to(prefix)
return str(filepath) | 264 | 23.090909 | 47 | py |
DeepSpectrum | DeepSpectrum-master/src/deepspectrum/tools/__init__.py | 0 | 0 | 0 | py | |
DeepSpectrum | DeepSpectrum-master/src/deepspectrum/backend/plotting.py | import matplotlib
import io
import warnings
# import librosa.display
# import librosa
import numpy as np
import pathlib
import logging
from imread import imread_from_blob
from os import environ, makedirs
from os.path import basename, join, dirname, splitext
from multiprocessing import cpu_count, Pool
from functools imp... | 12,163 | 35.310448 | 193 | py |
DeepSpectrum | DeepSpectrum-master/src/deepspectrum/backend/extractor.py | import gc
from collections import namedtuple
import numpy as np
import os
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3"
import tensorflow as tf
import torch
from torchvision import models, transforms
from PIL import Image
import logging
tf.compat.v1.logging.set_verbosity(logging.ERROR)
log = logging.getLogger(__name__)
... | 11,743 | 33.745562 | 115 | py |
DeepSpectrum | DeepSpectrum-master/src/deepspectrum/backend/__init__.py | 0 | 0 | 0 | py | |
DeepSpectrum | DeepSpectrum-master/tests/__init__.py | 0 | 0 | 0 | py | |
DeepSpectrum | DeepSpectrum-master/tests/cli/test_features.py | from multiprocessing import cpu_count
from deepspectrum.__main__ import cli
from click.testing import CliRunner
from os.path import dirname, join
from os import listdir
cur_dir = dirname(__file__)
examples = join(dirname(dirname(cur_dir)), 'examples')
def test_features_file_level(tmpdir):
runner = CliRunner()
... | 4,456 | 41.855769 | 79 | py |
DeepSpectrum | DeepSpectrum-master/tests/cli/test_image_features.py | from click.testing import CliRunner
from deepspectrum.__main__ import cli
from multiprocessing import cpu_count
from os.path import join, dirname
cur_dir = dirname(__file__)
examples = join(dirname(dirname(cur_dir)), 'examples')
def test_image_features(tmpdir):
runner = CliRunner()
result = runner.invoke(cli... | 805 | 34.043478 | 74 | py |
DeepSpectrum | DeepSpectrum-master/tests/cli/test_plot.py | from click.testing import CliRunner
from deepspectrum.__main__ import cli
from multiprocessing import cpu_count
from os.path import join, dirname
cur_dir = dirname(__file__)
examples = join(dirname(dirname(cur_dir)), 'examples')
def test_plot(tmpdir):
runner = CliRunner()
result = runner.invoke(cli,
... | 966 | 37.68 | 79 | py |
DeepSpectrum | DeepSpectrum-master/tests/cli/__init__.py | 0 | 0 | 0 | py | |
ocp | ocp-main/main.py | """
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
import argparse
import copy
import logging
import submitit
from ocpmodels.common.flags import flags
from ocpmodels.common.utils import (
... | 2,904 | 31.277778 | 79 | py |
ocp | ocp-main/setup.py | """
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
from setuptools import find_packages, setup
setup(
name="ocp-models",
version="0.0.3",
description="Machine learning models for ... | 495 | 26.555556 | 100 | py |
ocp | ocp-main/scripts/preprocess_relaxed.py | """
Creates LMDB files with extracted graph features from provided *.extxyz files
for the S2EF task.
"""
import argparse
import glob
import multiprocessing as mp
import os
import pickle
import random
import sys
import ase.io
import lmdb
import numpy as np
import torch
from tqdm import tqdm
from ocpmodels.preprocessi... | 3,388 | 22.212329 | 82 | py |
ocp | ocp-main/scripts/download_data.py | import argparse
import glob
import logging
import os
from typing import Dict, Optional
import ocpmodels
"""
This script provides users with an automated way to download, preprocess (where
applicable), and organize data to readily be used by the existing config files.
"""
DOWNLOAD_LINKS_s2ef: Dict[str, Dict[str, str]... | 6,512 | 34.016129 | 127 | py |
ocp | ocp-main/scripts/make_submission_file.py | """
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
import argparse
import glob
import os
import numpy as np
SPLITS = {
"OC20": ["id", "ood_ads", "ood_cat", "ood_both"],
"OC22": ["id"... | 4,862 | 31.637584 | 120 | py |
ocp | ocp-main/scripts/preprocess_ef.py | """
Creates LMDB files with extracted graph features from provided *.extxyz files
for the S2EF task.
"""
import argparse
import glob
import multiprocessing as mp
import os
import pickle
import random
import sys
import ase.io
import lmdb
import numpy as np
import torch
from tqdm import tqdm
from ocpmodels.preprocessi... | 4,893 | 27.453488 | 111 | py |
ocp | ocp-main/scripts/gif_maker_parallelized.py | """
Script to generate gifs from traj
Note:
This is just a quick way to generate gifs and visalizations from traj, there are many parameters and settings in the code that people can vary to make visualizations better. We have chosen these settings as this seem to work fine for most of our systems.
Requirements:
povr... | 4,145 | 32.168 | 254 | py |
ocp | ocp-main/scripts/make_lmdb_sizes.py | """
This script provides the functionality to generate metadata.npz files necessary
for load_balancing the DataLoader.
"""
import argparse
import multiprocessing as mp
import os
import warnings
import numpy as np
from tqdm import tqdm
from ocpmodels.datasets import SinglePointLmdbDataset, TrajectoryLmdbDataset
from ... | 2,225 | 26.481481 | 98 | py |
ocp | ocp-main/scripts/__init__.py | """
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
| 178 | 24.571429 | 63 | py |
ocp | ocp-main/scripts/uncompress.py | """
Uncompresses downloaded S2EF datasets to be used by the LMDB preprocessing
script - preprocess_ef.py
"""
import argparse
import glob
import lzma
import multiprocessing as mp
import os
from typing import List, Tuple
from tqdm import tqdm
def read_lzma(inpfile: str, outfile: str) -> None:
with open(inpfile, "... | 1,819 | 25.376812 | 78 | py |
ocp | ocp-main/scripts/make_challenge_submission_file.py | """
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
ONLY for use in the NeurIPS 2021 Open Catalyst Challenge. For all other submissions
please use make_submission_file.py.
"""
import argparse
imp... | 3,667 | 29.823529 | 113 | py |
ocp | ocp-main/scripts/hpo/run_tune.py | import os
import ray
from ray import tune
from ray.tune import CLIReporter
from ray.tune.schedulers import ASHAScheduler
from ocpmodels.common.flags import flags
from ocpmodels.common.registry import registry
from ocpmodels.common.utils import build_config, setup_imports
# this function is general and should work f... | 3,426 | 29.598214 | 80 | py |
ocp | ocp-main/scripts/hpo/run_tune_pbt.py | import logging
import os
import ray
from ray import tune
from ray.tune import CLIReporter
from ray.tune.schedulers import PopulationBasedTraining
from ocpmodels.common.flags import flags
from ocpmodels.common.registry import registry
from ocpmodels.common.utils import build_config, setup_imports
# this function is ... | 3,355 | 29.509091 | 74 | py |
ocp | ocp-main/scripts/hpo/__init__.py | """
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
| 178 | 24.571429 | 63 | py |
ocp | ocp-main/tests/conftest.py | """
Copyright (c) Facebook, Inc. and its 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 TYPE_CHECKING, Optional, Union
import numpy as np
import pytest
from syrupy.extensions.amber import AmberSnapshotExtensio... | 5,137 | 33.02649 | 98 | py |
ocp | ocp-main/tests/__init__.py | """
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
| 178 | 24.571429 | 63 | py |
ocp | ocp-main/tests/common/test_data_parallel_batch_sampler.py | import tempfile
from contextlib import contextmanager
from pathlib import Path
from typing import TypeVar
import numpy as np
import pytest
from torch.utils.data import Dataset
from ocpmodels.common.data_parallel import BalancedBatchSampler
DATA = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
SIZE_ATOMS = [1, 1, 1, 1, 1, 1, 1, 1, ... | 6,251 | 25.05 | 161 | py |
ocp | ocp-main/tests/models/test_schnet.py | """
Copyright (c) Facebook, Inc. and its 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 random
import numpy as np
import pytest
import torch
from ase.io import read
from ocpmodels.common.registry import registr... | 2,649 | 28.120879 | 79 | py |
ocp | ocp-main/tests/models/test_gemnet_oc.py | """
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
import io
import logging
import os
import random
import numpy as np
import pytest
import requests
import torch
from ase.io import read
from... | 4,631 | 27.95 | 120 | py |
ocp | ocp-main/tests/models/test_gemnet.py | """
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
import logging
import os
import random
import numpy as np
import pytest
import torch
from ase.io import read
from ocpmodels.common.registry... | 3,191 | 27 | 79 | py |
ocp | ocp-main/tests/models/test_dimenet.py | """
Copyright (c) Facebook, Inc. and its 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 random
import numpy as np
import pytest
import torch
from ase.io import read
from ocpmodels.common.registry import registr... | 2,693 | 27.0625 | 79 | py |
ocp | ocp-main/tests/models/test_cgcnn.py | """
Copyright (c) Facebook, Inc. and its 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 random
import numpy as np
import pytest
import torch
from ase.io import read
from ocpmodels.common.registry import registr... | 2,759 | 27.163265 | 79 | py |
ocp | ocp-main/tests/models/test_forcenet.py | """
Copyright (c) Facebook, Inc. and its 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 numpy as np
import pytest
from ase.io import read
from ocpmodels.common.registry import registry
from ocpmodels.common.uti... | 1,657 | 24.121212 | 79 | py |
ocp | ocp-main/tests/models/test_gemnet_oc_scaling_mismatch.py | """
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
import io
import pytest
import requests
import torch
from ocpmodels.common.registry import registry
from ocpmodels.common.utils import load... | 9,850 | 31.511551 | 124 | py |
ocp | ocp-main/tests/models/test_dimenetpp.py | """
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
import logging
import os
import random
import numpy as np
import pytest
import torch
from ase.io import read
from ocpmodels.common.registry... | 2,745 | 27.020408 | 79 | py |
ocp | ocp-main/tests/evaluator/test_evaluator.py | """
Copyright (c) Facebook, Inc. and its 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
import pytest
import torch
from ocpmodels.modules.evaluator import (
Evaluator,
cosine_similarity,
magnitude_... | 3,210 | 28.731481 | 72 | py |
ocp | ocp-main/tests/datasets/test_ase_lmdb.py | import os
from pathlib import Path
import numpy as np
import pytest
import tqdm
from ase import build
from ase.calculators.singlepoint import SinglePointCalculator
from ase.constraints import FixAtoms
from ase.io import write
from ocpmodels.datasets.lmdb_database import LMDBDatabase
DB_NAME = "ase_lmdb.lmdb"
N_WRITE... | 4,513 | 24.942529 | 80 | py |
ocp | ocp-main/tests/datasets/test_ase_datasets.py | import os
import numpy as np
import pytest
from ase import build, db
from ase.calculators.singlepoint import SinglePointCalculator
from ase.io import Trajectory, write
from ocpmodels.datasets import (
AseDBDataset,
AseReadDataset,
AseReadMultiStructureDataset,
)
from ocpmodels.datasets.lmdb_database impor... | 11,501 | 25.441379 | 103 | py |
ocp | ocp-main/tests/preprocessing/test_radius_graph_pbc.py | """
Copyright (c) Facebook, Inc. and its 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 ase
import numpy as np
import pytest
import torch
from ase.io import read
from ase.lattice.cubic import FaceCenteredCubic
f... | 7,781 | 28.589354 | 79 | py |
ocp | ocp-main/tests/preprocessing/test_atoms_to_graphs.py | """
Copyright (c) Facebook, Inc. and its 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 numpy as np
import pytest
from ase.io import read
from ase.neighborlist import NeighborList, NewPrimitiveNeighborList
from... | 4,715 | 34.727273 | 79 | py |
ocp | ocp-main/tests/preprocessing/test_pbc.py | """
Copyright (c) Facebook, Inc. and its 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 numpy as np
import pytest
from ase.io import read
from ocpmodels.common.utils import get_pbc_distances
from ocpmodels.data... | 1,433 | 24.607143 | 79 | py |
ocp | ocp-main/tests/preprocessing/__init__.py | """
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
| 178 | 24.571429 | 63 | py |
ocp | ocp-main/docs/source/conf.py | """
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# l... | 2,204 | 30.956522 | 79 | py |
ocp | ocp-main/ocpmodels/__init__.py | """
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
| 178 | 24.571429 | 63 | py |
ocp | ocp-main/ocpmodels/modules/normalizer.py | """
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
import torch
class Normalizer:
"""Normalize a Tensor and restore it later."""
def __init__(self, tensor=None, mean=None, std=None,... | 1,390 | 28.595745 | 78 | py |
ocp | ocp-main/ocpmodels/modules/loss.py | import logging
from typing import Optional
import torch
from torch import nn
from ocpmodels.common import distutils
class L2MAELoss(nn.Module):
def __init__(self, reduction: str = "mean") -> None:
super().__init__()
self.reduction = reduction
assert reduction in ["mean", "sum"]
def ... | 2,597 | 29.564706 | 72 | py |
ocp | ocp-main/ocpmodels/modules/exponential_moving_average.py | """
Copied (and improved) from:
https://github.com/fadel/pytorch_ema/blob/master/torch_ema/ema.py (MIT license)
"""
from __future__ import division, unicode_literals
import copy
import weakref
from typing import List, Iterable, Optional
import torch
from ocpmodels.common.typing import none_throws
# Partially based... | 7,758 | 37.410891 | 99 | py |
ocp | ocp-main/ocpmodels/modules/scheduler.py | import inspect
import torch.optim.lr_scheduler as lr_scheduler
from ocpmodels.common.utils import warmup_lr_lambda
class LRScheduler:
"""
Learning rate scheduler class for torch.optim learning rate schedulers
Notes:
If no learning rate scheduler is specified in the config the default
sc... | 2,342 | 33.970149 | 81 | py |
ocp | ocp-main/ocpmodels/modules/evaluator.py | """
Copyright (c) Facebook, Inc. and its 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
import torch
from typing import Dict, Union
"""
An evaluation module for use with the OCP dataset and suite of tasks. It... | 9,085 | 28.028754 | 79 | py |
ocp | ocp-main/ocpmodels/modules/__init__.py | """
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
| 178 | 24.571429 | 63 | py |
ocp | ocp-main/ocpmodels/modules/scaling/fit.py | import logging
import math
import readline
import sys
from itertools import islice
from pathlib import Path
from typing import TYPE_CHECKING, Dict, Literal
import torch
import torch.nn as nn
from torch.nn.parallel.distributed import DistributedDataParallel
from ocpmodels.common.data_parallel import OCPDataParallel
fr... | 8,347 | 33.495868 | 112 | py |
ocp | ocp-main/ocpmodels/modules/scaling/scale_factor.py | import itertools
import logging
import math
from contextlib import contextmanager
from typing import Callable, Optional, TypedDict, Union
import torch
import torch.nn as nn
class _Stats(TypedDict):
variance_in: float
variance_out: float
n_samples: int
IndexFn = Callable[[], None]
def _check_consisten... | 4,613 | 25.67052 | 89 | py |
ocp | ocp-main/ocpmodels/modules/scaling/util.py | import logging
import torch.nn as nn
from .scale_factor import ScaleFactor
def ensure_fitted(module: nn.Module, warn: bool = False) -> None:
for name, child in module.named_modules():
if not isinstance(child, ScaleFactor) or child.fitted:
continue
if child.name is not None:
... | 786 | 31.791667 | 96 | py |
ocp | ocp-main/ocpmodels/modules/scaling/__init__.py | from .scale_factor import ScaleFactor
__all__ = ["ScaleFactor"]
| 65 | 15.5 | 37 | py |
ocp | ocp-main/ocpmodels/modules/scaling/compat.py | import json
import logging
from pathlib import Path
from typing import Dict, Optional, Union
import torch
import torch.nn as nn
from .scale_factor import ScaleFactor
ScaleDict = Union[Dict[str, float], Dict[str, torch.Tensor]]
def _load_scale_dict(scale_file: Optional[Union[str, ScaleDict]]):
"""
Loads sca... | 2,303 | 28.922078 | 111 | py |
ocp | ocp-main/ocpmodels/common/distutils.py | """
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
import logging
import os
import subprocess
import torch
import torch.distributed as dist
from ocpmodels.common.typing import none_throws
d... | 5,803 | 32.165714 | 94 | py |
ocp | ocp-main/ocpmodels/common/data_parallel.py | """
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
import heapq
import logging
from itertools import chain
from pathlib import Path
from typing import List, Literal, Protocol, Union, runtime_c... | 9,608 | 32.597902 | 126 | py |
ocp | ocp-main/ocpmodels/common/registry.py | """
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
# Copyright (c) Facebook, Inc. and its affiliates.
# Borrowed from https://github.com/facebookresearch/pythia/blob/master/pythia/common/regis... | 9,503 | 29.267516 | 111 | py |
ocp | ocp-main/ocpmodels/common/typing.py | from typing import Optional, TypeVar, Type
_T = TypeVar("_T")
def assert_is_instance(obj: object, cls: Type[_T]) -> _T:
if not isinstance(obj, cls):
raise TypeError(f"obj is not an instance of cls: obj={obj}, cls={cls}")
return obj
def none_throws(x: Optional[_T], msg: Optional[str] = None) -> _T:
... | 464 | 23.473684 | 79 | py |
ocp | ocp-main/ocpmodels/common/utils.py | """
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
import ast
import collections
import copy
import importlib
import itertools
import json
import logging
import os
import sys
import time
from ... | 38,297 | 33.072954 | 128 | py |
ocp | ocp-main/ocpmodels/common/logger.py | """
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
import logging
from abc import ABC, abstractmethod
import torch
import wandb
from torch.utils.tensorboard import SummaryWriter
from ocpmodel... | 3,275 | 27 | 75 | py |
ocp | ocp-main/ocpmodels/common/flags.py | """
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
import argparse
from pathlib import Path
class Flags:
def __init__(self) -> None:
self.parser = argparse.ArgumentParser(
... | 4,659 | 31.137931 | 93 | py |
ocp | ocp-main/ocpmodels/common/__init__.py | """
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
| 178 | 24.571429 | 63 | py |
ocp | ocp-main/ocpmodels/common/gp_utils.py | """
Copyright (c) Facebook, Inc. and its 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
from typing import Any, Optional
import torch
from torch import distributed as dist
"""
Functions to support graph parallel trai... | 8,667 | 27.234528 | 97 | py |
ocp | ocp-main/ocpmodels/common/transforms.py | """
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
# Borrowed from https://github.com/rusty1s/pytorch_geometric/blob/master/torch_geometric/transforms/random_rotate.py
# with changes to keep t... | 3,003 | 36.55 | 116 | py |
ocp | ocp-main/ocpmodels/common/hpo_utils.py | """
Copyright (c) Facebook, Inc. and its 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
from ray import tune
def tune_reporter(
iters,
train_metrics,
val_metrics,
test_metrics=None,
metric_to_op... | 1,686 | 29.125 | 135 | py |
ocp | ocp-main/ocpmodels/common/relaxation/ase_utils.py | """
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
Utilities to interface OCP models/trainers with the Atomic Simulation
Environment (ASE)
"""
import copy
import logging
import os
import torch
... | 7,362 | 33.406542 | 145 | py |
ocp | ocp-main/ocpmodels/common/relaxation/__init__.py | 0 | 0 | 0 | py | |
ocp | ocp-main/ocpmodels/common/relaxation/ml_relaxation.py | """
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
import logging
from collections import deque
from pathlib import Path
import torch
from torch_geometric.data import Batch
from ocpmodels.co... | 2,786 | 29.626374 | 106 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.