repo
stringlengths
1
99
file
stringlengths
13
215
code
stringlengths
12
59.2M
file_length
int64
12
59.2M
avg_line_length
float64
3.82
1.48M
max_line_length
int64
12
2.51M
extension_type
stringclasses
1 value
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/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/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/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/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
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/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/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_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/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/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/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/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/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/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/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/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
ocp
ocp-main/ocpmodels/common/relaxation/optimizers/lbfgs_torch.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 from typing import Deque, Optional import ase import torch from torch_...
7,832
31.502075
79
py
ocp
ocp-main/ocpmodels/models/base.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 torch import torch.nn as nn from torch_geometric.nn import radius_graph from ocpmodels.common.utils import ( comp...
3,688
27.596899
94
py
ocp
ocp-main/ocpmodels/models/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 torch from torch import nn from torch_geometric.nn import DimeNet, radius_graph from torch_scatter import scatter from torch_sparse im...
8,211
34.549784
98
py
ocp
ocp-main/ocpmodels/models/dimenet_plus_plus.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. --- This code borrows heavily from the DimeNet implementation as part of pytorch-geometric: https://github.com/rusty1s/pytorch_geometric. Licens...
15,691
32.175476
80
py
ocp
ocp-main/ocpmodels/models/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. """ from math import pi as PI from typing import Optional import numpy as np import torch import torch.nn as nn from torch_geometric.nn import M...
18,340
34.339114
124
py
ocp
ocp-main/ocpmodels/models/spinconv.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 import time from math import pi as PI import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from ...
43,927
33.372457
137
py
ocp
ocp-main/ocpmodels/models/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 torch from torch_geometric.nn import SchNet from torch_scatter import scatter from ocpmodels.common.registry import registry from ocp...
4,755
32.258741
98
py
ocp
ocp-main/ocpmodels/models/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 torch import torch.nn as nn from torch_geometric.nn import MessagePassing, global_mean_pool, radius_graph from torch_geometric.nn.mode...
8,190
33.855319
142
py
ocp
ocp-main/ocpmodels/models/gemnet/initializers.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 def _standardize(kernel): """ Makes sure that N*Var(W) = 1 and E[W] = 0 """ eps = 1e-6 if len(kernel.shap...
1,385
27.875
92
py
ocp
ocp-main/ocpmodels/models/gemnet/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. """ from typing import Optional import numpy as np import torch from torch_geometric.nn import radius_graph from torch_scatter import scatter fr...
20,301
32.724252
118
py
ocp
ocp-main/ocpmodels/models/gemnet/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 json import torch from torch_scatter import segment_csr def read_json(path: str): """""" if not path.endswith(".json"): ...
9,228
31.960714
128
py
ocp
ocp-main/ocpmodels/models/gemnet/layers/base_layers.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 import torch from ..initializers import he_orthogonal_init class Dense(torch.nn.Module): """ Combines dense layer wit...
3,001
24.87931
76
py
ocp
ocp-main/ocpmodels/models/gemnet/layers/atom_update_block.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 from torch_scatter import scatter from ocpmodels.modules.scaling import ScaleFactor from ..initializers import he_orthogonal_i...
6,443
30.281553
107
py
ocp
ocp-main/ocpmodels/models/gemnet/layers/embedding_block.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 .base_layers import Dense class AtomEmbedding(torch.nn.Module): """ Initial atom embeddings b...
2,424
23.25
92
py
ocp
ocp-main/ocpmodels/models/gemnet/layers/radial_basis.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 Dict, Union import numpy as np import torch from scipy.special import binom from torch_geometric.nn.models.sc...
6,434
29.353774
77
py
ocp
ocp-main/ocpmodels/models/gemnet/layers/spherical_basis.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 sympy as sym import torch from torch_geometric.nn.models.schnet import GaussianSmearing from .basis_utils import real_sph_harm from ....
3,221
32.216495
86
py
ocp
ocp-main/ocpmodels/models/gemnet/layers/interaction_block.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 import torch from ocpmodels.modules.scaling.scale_factor import ScaleFactor from .atom_update_block import AtomUpdateBlock fro...
10,381
29.356725
118
py
ocp
ocp-main/ocpmodels/models/gemnet/layers/efficient.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 from ..initializers import he_orthogonal_init class EfficientInteractionDownProjection(torch.nn.Module): """ Down pro...
5,005
27.770115
81
py
ocp
ocp-main/ocpmodels/models/painn/painn.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. --- MIT License Copyright (c) 2021 www.compscience.org Permission is hereby granted, free of charge, to any person obtaining a copy of this so...
21,957
32.472561
96
py
ocp
ocp-main/ocpmodels/models/painn/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 torch from torch_scatter import segment_csr def repeat_blocks( sizes, repeats, continuous_indexing: bool = True, sta...
6,138
35.325444
128
py
ocp
ocp-main/ocpmodels/models/escn/so3.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 torch import torch.nn as nn try: from e3nn import o3 from e3nn.o3 import FromS2Grid, ToS2Grid except ImportError: ...
19,050
32.422807
112
py
ocp
ocp-main/ocpmodels/models/escn/escn.py
""" Copyright (c) Meta, 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 time from typing import List import numpy as np import torch import torch.nn as nn from pyexpat.model import XML_CQUANT_OP...
34,881
33.951904
126
py
ocp
ocp-main/ocpmodels/models/scn/scn.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 sys import time import numpy as np import torch import torch.nn as nn from torch_geometric.nn import radius_graph fro...
30,218
35.060859
136
py
ocp
ocp-main/ocpmodels/models/scn/smearing.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 import torch.nn as nn # Different encodings for the atom distance embeddings class GaussianSmearing(torch.nn.Module): def ...
2,803
31.229885
77
py
ocp
ocp-main/ocpmodels/models/scn/spherical_harmonics.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 math import os import torch try: from e3nn import o3 from e3nn.o3 import FromS2Grid, ToS2Grid # Borrowed...
14,397
36.397403
122
py
ocp
ocp-main/ocpmodels/models/scn/sampling.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 import torch ### Methods for sample points on a sphere def CalcSpherePoints(num_points: int, device: str = "cpu") -> torch.Ten...
1,527
31.510638
79
py
ocp
ocp-main/ocpmodels/models/gemnet_gp/initializers.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 def _standardize(kernel): """ Makes sure that N*Var(W) = 1 and E[W] = 0 """ eps = 1e-6 if len(kernel.shap...
1,385
27.875
92
py
ocp
ocp-main/ocpmodels/models/gemnet_gp/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. """ from typing import Optional import numpy as np import torch from torch_cluster import radius_graph from torch_scatter import scatter from to...
22,203
33.16
118
py
ocp
ocp-main/ocpmodels/models/gemnet_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 json from typing import Optional, Tuple import torch from torch_scatter import segment_csr def read_json(path: str): """""" ...
9,439
32.006993
128
py
ocp
ocp-main/ocpmodels/models/gemnet_gp/layers/base_layers.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 Optional import torch from ..initializers import he_orthogonal_init class Dense(torch.nn.Module): """ ...
3,247
25.406504
71
py
ocp
ocp-main/ocpmodels/models/gemnet_gp/layers/atom_update_block.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 Optional import torch from torch_scatter import scatter from torch_scatter.utils import broadcast from ocpmodels.common ...
7,813
30.256
107
py
ocp
ocp-main/ocpmodels/models/gemnet_gp/layers/embedding_block.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 Optional import numpy as np import torch from ocpmodels.common import gp_utils from .base_layers import Dense class A...
2,621
23.735849
92
py
ocp
ocp-main/ocpmodels/models/gemnet_gp/layers/radial_basis.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 Dict, Union import numpy as np import torch from scipy.special import binom from ocpmodels.common.typing impo...
6,381
29.103774
77
py
ocp
ocp-main/ocpmodels/models/gemnet_gp/layers/spherical_basis.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 sympy as sym import torch from torch_geometric.nn.models.schnet import GaussianSmearing from ocpmodels.common.typing import assert_is_...
3,221
32.216495
86
py
ocp
ocp-main/ocpmodels/models/gemnet_gp/layers/interaction_block.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 Optional import torch from ocpmodels.common import gp_utils from ocpmodels.modules.scaling import ScaleFacto...
11,227
30.016575
118
py
ocp
ocp-main/ocpmodels/models/gemnet_gp/layers/efficient.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 Tuple import torch from ..initializers import he_orthogonal_init class EfficientInteractionDownProjection(torch.nn.Mod...
4,957
27.170455
81
py
ocp
ocp-main/ocpmodels/models/gemnet_oc/initializers.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 functools import partial import torch def _standardize(kernel): """ Makes sure that N*Var(W) = 1 and E[W] = 0 """ eps ...
2,765
27.8125
137
py
ocp
ocp-main/ocpmodels/models/gemnet_oc/interaction_indices.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 from torch_scatter import segment_coo from torch_sparse import SparseTensor from .utils import get_inner_idx, masked_select_spar...
10,507
32.787781
86
py
ocp
ocp-main/ocpmodels/models/gemnet_oc/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 logging import os from typing import Dict, Optional, Union import numpy as np import torch from torch_geometric.nn import radius_graph...
48,949
34.834553
93
py
ocp
ocp-main/ocpmodels/models/gemnet_oc/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 numpy as np import torch from torch_scatter import segment_coo, segment_csr from torch_sparse import SparseTensor def ragged_range(si...
14,529
33.188235
128
py
ocp
ocp-main/ocpmodels/models/gemnet_oc/layers/base_layers.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 import torch from ..initializers import he_orthogonal_init class Dense(torch.nn.Module): """ Combines dense layer with...
2,826
25.175926
76
py
ocp
ocp-main/ocpmodels/models/gemnet_oc/layers/atom_update_block.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 import torch from torch_scatter import scatter from ocpmodels.common.utils import scatter_det from ocpmodels.modules.scaling imp...
5,833
28.614213
78
py
ocp
ocp-main/ocpmodels/models/gemnet_oc/layers/embedding_block.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 .base_layers import Dense class AtomEmbedding(torch.nn.Module): """ Initial atom embeddings ba...
2,622
24.715686
72
py
ocp
ocp-main/ocpmodels/models/gemnet_oc/layers/radial_basis.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 Dict, Union import numpy as np import sympy as sym import torch from scipy.special import binom from ocpmodel...
7,675
29.827309
77
py
ocp
ocp-main/ocpmodels/models/gemnet_oc/layers/basis_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 import numpy as np import sympy as sym import torch from scipy import special as sp from scipy.optimize import brentq def Jn(r:...
11,335
32.838806
121
py
ocp
ocp-main/ocpmodels/models/gemnet_oc/layers/force_scaler.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 torch class ForceScaler: """ Scales up the energy and then scales down the forces to prevent NaNs and inf...
3,081
31.442105
77
py
ocp
ocp-main/ocpmodels/models/gemnet_oc/layers/spherical_basis.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 from ocpmodels.modules.scaling import ScaleFactor from .basis_utils import get_sph_harm_basis from .radial_basis import Gaussia...
4,369
29.347222
79
py
ocp
ocp-main/ocpmodels/models/gemnet_oc/layers/interaction_block.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 import torch from ocpmodels.modules.scaling import ScaleFactor from .atom_update_block import AtomUpdateBlock from .base_layers...
23,476
29.931489
85
py
ocp
ocp-main/ocpmodels/models/gemnet_oc/layers/efficient.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 Optional import torch from torch_scatter import scatter from ..initializers import he_orthogonal_init from .base_layers i...
9,599
34.555556
89
py
ocp
ocp-main/ocpmodels/models/utils/activations.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 import torch.nn.functional as F class Act(torch.nn.Module): def __init__(self, act: str, slope: float = 0.05) -> None: ...
1,650
33.395833
74
py
ocp
ocp-main/ocpmodels/models/utils/basis.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 List, Optional import numpy as np import torch import torch.nn as nn from scipy.special import sph_harm from ...
10,366
32.659091
122
py
ocp
ocp-main/ocpmodels/datasets/oc22_lmdb_dataset.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 bisect import logging import math import pickle import random import warnings from pathlib import Path import lmdb import numpy as np...
8,611
35.961373
103
py
ocp
ocp-main/ocpmodels/datasets/lmdb_dataset.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 bisect import logging import math import pickle import random import warnings from pathlib import Path from typing import Optional, Typ...
9,163
35.07874
85
py
ocp
ocp-main/ocpmodels/datasets/ase_datasets.py
import bisect import copy import functools import glob import logging import os import warnings from pathlib import Path from abc import ABC, abstractmethod from typing import List import ase import numpy as np from torch import tensor from torch.utils.data import Dataset from tqdm import tqdm from ocpmodels.common.r...
18,646
36.145418
114
py
ocp
ocp-main/ocpmodels/tasks/task.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 from ocpmodels.common.registry import registry from ocpmodels.trainers.forces_trainer import ForcesTrainer class ...
3,181
31.141414
135
py
ocp
ocp-main/ocpmodels/preprocessing/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. """ from typing import Optional import ase.db.sqlite import ase.io.trajectory import numpy as np import torch from torch_geometric.data import D...
10,360
40.115079
119
py
ocp
ocp-main/ocpmodels/trainers/base_trainer.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 datetime import errno import logging import os import random import subprocess from abc import ABC, abstractmethod from collections imp...
29,997
36.264596
111
py
ocp
ocp-main/ocpmodels/trainers/energy_trainer.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 typing import Optional import torch import torch_geometric from tqdm import tqdm from ocpmodels.common import distutils...
11,855
33.768328
129
py