Search is not available for this dataset
repo stringlengths 2 152 ⌀ | file stringlengths 15 239 | code stringlengths 0 58.4M | file_length int64 0 58.4M | avg_line_length float64 0 1.81M | max_line_length int64 0 12.7M | extension_type stringclasses 364
values |
|---|---|---|---|---|---|---|
realistic-ssl-evaluation-pytorch | realistic-ssl-evaluation-pytorch-master/lib/datasets/svhn.py | import numpy as np
import os
class SVHN:
def __init__(self, root, split="l_train"):
self.dataset = np.load(os.path.join(root, "svhn", split+".npy"), allow_pickle=True).item()
def __getitem__(self, idx):
image = self.dataset["images"][idx]
label = self.dataset["labels"][idx]
ima... | 442 | 28.533333 | 98 | py |
null | e3_diffusion_for_molecules-main/README.md | # SILVR
This is a fork of repo: https://github.com/ehoogeboom/e3_diffusion_for_molecules. SILVR has been implemented as described in (insert paper). (add more details + scheme when public).
This repo only contains the core SILVR model. The notebooks required for the successful execution of SILVR are contained at (). I... | 1,677 | 128.076923 | 575 | md |
null | e3_diffusion_for_molecules-main/analyse_geom.py | from rdkit import Chem
import os
import numpy as np
import torch
from torch.utils.data import BatchSampler, DataLoader, Dataset, SequentialSampler
import argparse
import collections
import pickle
import os
import json
from tqdm import tqdm
from IPython.display import display
from matplotlib import pyplot as plt
import ... | 10,412 | 37.283088 | 125 | py |
null | e3_diffusion_for_molecules-main/build_geom_dataset.py | import msgpack
import os
import numpy as np
import torch
from torch.utils.data import BatchSampler, DataLoader, Dataset, SequentialSampler
import argparse
from qm9.data import collate as qm9_collate
def extract_conformers(args):
drugs_file = os.path.join(args.data_dir, args.data_file)
save_file = f"geom_drugs... | 9,281 | 36.885714 | 101 | py |
null | e3_diffusion_for_molecules-main/eval_analyze.py | # Rdkit import should be first, do not move it
try:
from rdkit import Chem
except ModuleNotFoundError:
pass
import utils
import argparse
from qm9 import dataset
from qm9.models import get_model
import os
from equivariant_diffusion.utils import assert_mean_zero_with_mask, remove_mean_with_mask,\
assert_corre... | 7,795 | 38.175879 | 120 | py |
null | e3_diffusion_for_molecules-main/eval_conditional_qm9.py | import argparse
from os.path import join
import torch
import pickle
from qm9.models import get_model
from configs.datasets_config import get_dataset_info
from qm9 import dataset
from qm9.utils import compute_mean_mad
from qm9.sampling import sample
from qm9.property_prediction.main_qm9_prop import test
from qm9.propert... | 10,394 | 43.613734 | 125 | py |
null | e3_diffusion_for_molecules-main/eval_sample.py | # Rdkit import should be first, do not move it
try:
from rdkit import Chem
except ModuleNotFoundError:
pass
import utils
import argparse
from configs.datasets_config import qm9_with_h, qm9_without_h
from qm9 import dataset
from qm9.models import get_model
from equivariant_diffusion.utils import assert_correct... | 5,606 | 32.981818 | 90 | py |
null | e3_diffusion_for_molecules-main/main_geom_drugs.py | # Rdkit import should be first, do not move it
try:
from rdkit import Chem
except ModuleNotFoundError:
pass
import build_geom_dataset
from configs.datasets_config import geom_with_h
import copy
import utils
import argparse
import wandb
from os.path import join
from qm9.models import get_optim, get_model
from eq... | 12,752 | 44.384342 | 138 | py |
null | e3_diffusion_for_molecules-main/main_qm9.py | # Rdkit import should be first, do not move it
try:
from rdkit import Chem
except ModuleNotFoundError:
pass
import copy
import utils
import argparse
import wandb
from configs.datasets_config import get_dataset_info
from os.path import join
from qm9 import dataset
from qm9.models import get_optim, get_model
from... | 13,079 | 44.103448 | 118 | py |
null | e3_diffusion_for_molecules-main/setup.py | from setuptools import setup, find_packages
setup(
name='EN_diffusion',
version='1.0.0',
url=None,
author='Author Name',
author_email='author@gmail.com',
description='Description of my package',
packages=find_packages(),
install_requires=['numpy >= 1.11.1', 'matplotlib >= 1.5.1']
) | 315 | 25.333333 | 63 | py |
null | e3_diffusion_for_molecules-main/train_test.py | import wandb
from equivariant_diffusion.utils import assert_mean_zero_with_mask, remove_mean_with_mask,\
assert_correctly_masked, sample_center_gravity_zero_gaussian_with_mask
import numpy as np
import qm9.visualizer as vis
from qm9.analyze import analyze_stability_for_molecules
from qm9.sampling import sample_chai... | 9,409 | 44.240385 | 117 | py |
null | e3_diffusion_for_molecules-main/utils.py | import numpy as np
import getpass
import os
import torch
# Folders
def create_folders(args):
try:
os.makedirs('outputs')
except OSError:
pass
try:
os.makedirs('outputs/' + args.exp_name)
except OSError:
pass
# Model checkpoints
def save_model(model, path):
torch.s... | 4,012 | 25.058442 | 74 | py |
null | e3_diffusion_for_molecules-main/configs/datasets_config.py |
qm9_with_h = {
'name': 'qm9',
'atom_encoder': {'H': 0, 'C': 1, 'N': 2, 'O': 3, 'F': 4},
'atom_decoder': ['H', 'C', 'N', 'O', 'F'],
'n_nodes': {22: 3393, 17: 13025, 23: 4848, 21: 9970, 19: 13832, 20: 9482, 16: 10644, 13: 3060,
15: 7796, 25: 1506, 18: 13364, 12: 1689, 11: 807, 24: 539, 1... | 10,128 | 64.348387 | 671 | py |
null | e3_diffusion_for_molecules-main/configs/qm9_config.yaml | # Experiment settings
exp_name: debug_10
dataset: 'qm9' # qm9, qm9_positional
filter_n_atoms: null # When set to an integer value, QM9 will only contain molecules of that amount of atoms
n_report_steps: 1
wandb_usr: cvignac
no_cuda: False
wandb: False # Use wandb?
online: True # ... | 1,791 | 29.372881 | 117 | yaml |
null | e3_diffusion_for_molecules-main/data/geom/README.md | # How to build GEOM-DRUGS
1. Download the file at https://dataverse.harvard.edu/file.xhtml?fileId=4360331&version=2.0 (Warning: 50gb):
`wget https://dataverse.harvard.edu/api/access/datafile/4360331`
2. Untar it and move it to data/geom/
`tar -xzvf 4360331`
3. `pip install msgpack`
4. `python3 build_geom_... | 331 | 35.888889 | 110 | md |
null | e3_diffusion_for_molecules-main/egnn/egnn.py | import torch
from torch import Tensor
from torch import nn
import torch.nn.functional as F
class E_GCL(nn.Module):
"""Graph Neural Net with global state and fixed number of nodes per graph.
Args:
hidden_dim: Number of hidden units.
num_nodes: Maximum number of nodes (for self-attentive poo... | 14,826 | 41.976812 | 264 | py |
null | e3_diffusion_for_molecules-main/egnn/egnn_new.py | from torch import nn
import torch
import math
class GCL(nn.Module):
def __init__(self, input_nf, output_nf, hidden_nf, normalization_factor, aggregation_method,
edges_in_d=0, nodes_att_dim=0, act_fn=nn.SiLU(), attention=False):
super(GCL, self).__init__()
input_edge = input_nf * 2
... | 12,294 | 43.709091 | 131 | py |
null | e3_diffusion_for_molecules-main/egnn/models.py | import torch
import torch.nn as nn
from egnn.egnn_new import EGNN, GNN
from equivariant_diffusion.utils import remove_mean, remove_mean_with_mask
import numpy as np
class EGNN_dynamics_QM9(nn.Module):
def __init__(self, in_node_nf, context_node_nf,
n_dims, hidden_nf=64, device='cpu',
... | 5,555 | 40.155556 | 107 | py |
null | e3_diffusion_for_molecules-main/equivariant_diffusion/__init__.py | 0 | 0 | 0 | py | |
null | e3_diffusion_for_molecules-main/equivariant_diffusion/distributions.py | import torch
from equivariant_diffusion.utils import \
center_gravity_zero_gaussian_log_likelihood_with_mask, \
standard_gaussian_log_likelihood_with_mask, \
center_gravity_zero_gaussian_log_likelihood, \
sample_center_gravity_zero_gaussian_with_mask, \
sample_center_gravity_zero_gaussian, \
sam... | 1,865 | 31.172414 | 80 | py |
null | e3_diffusion_for_molecules-main/equivariant_diffusion/en_diffusion.py | from equivariant_diffusion import utils
import numpy as np
import math
import torch
from egnn import models
from torch.nn import functional as F
from equivariant_diffusion import utils as diffusion_utils
# Defining some useful util functions.
def expm1(x: torch.Tensor) -> torch.Tensor:
return torch.expm1(x)
def... | 48,360 | 38.510621 | 178 | py |
null | e3_diffusion_for_molecules-main/equivariant_diffusion/utils.py | import torch
import numpy as np
class EMA():
def __init__(self, beta):
super().__init__()
self.beta = beta
def update_model_average(self, ma_model, current_model):
for current_params, ma_params in zip(current_model.parameters(), ma_model.parameters()):
old_weight, up_weigh... | 4,243 | 29.099291 | 96 | py |
null | e3_diffusion_for_molecules-main/generated_samples/gschnet/__init__.py | 0 | 0 | 0 | py | |
null | e3_diffusion_for_molecules-main/generated_samples/gschnet/analyze_gschnet.py | # Rdkit import should be first, do not move it
try:
from rdkit import Chem
except ModuleNotFoundError:
pass
import pickle
import torch.nn.functional as F
from qm9.analyze import analyze_stability_for_molecules
import numpy as np
import torch
def flatten_sample_dictionary(samples):
results = {'one_hot': [... | 1,647 | 29.518519 | 96 | py |
null | e3_diffusion_for_molecules-main/qm9/__init__.py | 0 | 0 | 0 | py | |
null | e3_diffusion_for_molecules-main/qm9/analyze.py | try:
from rdkit import Chem
from qm9.rdkit_functions import BasicMolecularMetrics
use_rdkit = True
except ModuleNotFoundError:
use_rdkit = False
import qm9.dataset as dataset
import torch
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import numpy as np
import scipy.stats as sp_... | 13,305 | 32.686076 | 594 | py |
null | e3_diffusion_for_molecules-main/qm9/bond_analyze.py | # Bond lengths from:
# http://www.wiredchemist.com/chemistry/data/bond_energies_lengths.html
# And:
# http://chemistry-reference.com/tables/Bond%20Lengths%20and%20Enthalpies.pdf
bonds1 = {'H': {'H': 74, 'C': 109, 'N': 101, 'O': 96, 'F': 92,
'B': 119, 'Si': 148, 'P': 144, 'As': 152, 'S': 134,
... | 9,764 | 30.5 | 79 | py |
null | e3_diffusion_for_molecules-main/qm9/dataset.py | from torch.utils.data import DataLoader
from qm9.data.args import init_argparse
from qm9.data.collate import PreprocessQM9
from qm9.data.utils import initialize_datasets
import os
def retrieve_dataloaders(cfg):
if 'qm9' in cfg.dataset:
batch_size = cfg.batch_size
num_workers = cfg.num_workers
... | 3,840 | 46.419753 | 127 | py |
null | e3_diffusion_for_molecules-main/qm9/losses.py | import torch
def sum_except_batch(x):
return x.view(x.size(0), -1).sum(dim=-1)
def assert_correctly_masked(variable, node_mask):
assert (variable * (1 - node_mask)).abs().sum().item() < 1e-8
def compute_loss_and_nll(args, generative_model, nodes_dist, x, h, node_mask, edge_mask, context):
bs, n_nodes,... | 1,067 | 25.04878 | 98 | py |
null | e3_diffusion_for_molecules-main/qm9/models.py | import torch
from torch.distributions.categorical import Categorical
import numpy as np
from egnn.models import EGNN_dynamics_QM9
from equivariant_diffusion.en_diffusion import EnVariationalDiffusion
def get_model(args, device, dataset_info, dataloader_train):
histogram = dataset_info['n_nodes']
in_node_nf ... | 6,334 | 34 | 109 | py |
null | e3_diffusion_for_molecules-main/qm9/rdkit_functions.py | from rdkit import Chem
import numpy as np
from qm9.bond_analyze import get_bond_order, geom_predictor
from . import dataset
import torch
from configs.datasets_config import get_dataset_info
import pickle
import os
def compute_qm9_smiles(dataset_name, remove_h):
'''
:param dataset_name: qm9 or qm9_second_half... | 7,154 | 35.136364 | 134 | py |
null | e3_diffusion_for_molecules-main/qm9/sampling.py | import numpy as np
import torch
import torch.nn.functional as F
from equivariant_diffusion.utils import assert_mean_zero_with_mask, remove_mean_with_mask,\
assert_correctly_masked
from qm9.analyze import check_stability
def rotate_chain(z):
assert z.size(0) == 1
z_h = z[:, :, 3:]
n_steps = 30
th... | 6,002 | 34.105263 | 160 | py |
null | e3_diffusion_for_molecules-main/qm9/utils.py | import torch
def compute_mean_mad(dataloaders, properties, dataset_name):
if dataset_name == 'qm9':
return compute_mean_mad_from_dataloader(dataloaders['train'], properties)
elif dataset_name == 'qm9_second_half' or dataset_name == 'qm9_second_half':
return compute_mean_mad_from_dataloader(dat... | 3,400 | 36.373626 | 92 | py |
null | e3_diffusion_for_molecules-main/qm9/visualizer.py | import torch
import numpy as np
import os
import glob
import random
import matplotlib
import imageio
matplotlib.use('Agg')
import matplotlib.pyplot as plt
from qm9 import bond_analyze
##############
### Files ####
###########-->
def save_xyz_file(path, one_hot, charges, positions, dataset_info, id_from=0, name='mol... | 15,855 | 34.002208 | 154 | py |
null | e3_diffusion_for_molecules-main/qm9/data/__init__.py | from qm9.data.utils import initialize_datasets
from qm9.data.collate import PreprocessQM9
from qm9.data.dataset_class import ProcessedDataset | 141 | 46.333333 | 51 | py |
null | e3_diffusion_for_molecules-main/qm9/data/args.py | import argparse
from math import inf
#### Argument parser ####
def setup_shared_args(parser):
"""
Sets up the argparse object for the qm9 dataset
Parameters
----------
parser : :class:`argparse.ArgumentParser`
Argument Parser with arguments.
Parameters
----------
p... | 14,008 | 46.488136 | 137 | py |
null | e3_diffusion_for_molecules-main/qm9/data/collate.py | import torch
def batch_stack(props):
"""
Stack a list of torch.tensors so they are padded to the size of the
largest tensor along each axis.
Parameters
----------
props : list of Pytorch Tensors
Pytorch tensors to stack
Returns
-------
props : Pytorch tensor
Stack... | 2,718 | 25.144231 | 103 | py |
null | e3_diffusion_for_molecules-main/qm9/data/dataset_class.py | import torch
from torch.utils.data import Dataset
import os
from itertools import islice
from math import inf
import logging
class ProcessedDataset(Dataset):
"""
Data structure for a pre-processed cormorant dataset. Extends PyTorch Dataset.
Parameters
----------
data : dict
Dictionary o... | 3,510 | 36.351064 | 175 | py |
null | e3_diffusion_for_molecules-main/qm9/data/utils.py | import torch
import numpy as np
import logging
import os
from torch.utils.data import DataLoader
from qm9.data.dataset_class import ProcessedDataset
from qm9.data.prepare import prepare_dataset
def initialize_datasets(args, datadir, dataset, subset=None, splits=None,
force_download=False, su... | 7,481 | 39.443243 | 136 | py |
null | e3_diffusion_for_molecules-main/qm9/data/prepare/__init__.py | from qm9.data.prepare.download import *
from qm9.data.prepare.process import *
from qm9.data.prepare.qm9 import *
from qm9.data.prepare.md17 import *
| 150 | 29.2 | 39 | py |
null | e3_diffusion_for_molecules-main/qm9/data/prepare/download.py | import logging
import os
from qm9.data.prepare.md17 import download_dataset_md17
from qm9.data.prepare.qm9 import download_dataset_qm9
def prepare_dataset(datadir, dataset, subset=None, splits=None, cleanup=True, force_download=False):
"""
Download and process dataset.
Parameters
----------
data... | 2,990 | 35.925926 | 137 | py |
null | e3_diffusion_for_molecules-main/qm9/data/prepare/md17.py | from os.path import join as join
import urllib.request
import numpy as np
import torch
import logging, os, urllib
from qm9.data.prepare.utils import download_data, is_int, cleanup_file
md17_base_url = 'http://quantum-machine.org/gdml/data/npz/'
md17_subsets = {'benzene': 'benzene_old_dft',
'uracil':... | 3,992 | 34.972973 | 156 | py |
null | e3_diffusion_for_molecules-main/qm9/data/prepare/process.py | import logging
import os
import torch
import tarfile
from torch.nn.utils.rnn import pad_sequence
charge_dict = {'H': 1, 'C': 6, 'N': 7, 'O': 8, 'F': 9}
def split_dataset(data, split_idxs):
"""
Splits a dataset according to the indices given.
Parameters
----------
data : dict
Dictionary t... | 6,929 | 33.137931 | 138 | py |
null | e3_diffusion_for_molecules-main/qm9/data/prepare/qm9.py | import numpy as np
import torch
import logging
import os
import urllib
from os.path import join as join
import urllib.request
from qm9.data.prepare.process import process_xyz_files, process_xyz_gdb9
from qm9.data.prepare.utils import download_data, is_int, cleanup_file
def download_dataset_qm9(datadir, dataname, s... | 8,060 | 34.355263 | 114 | py |
null | e3_diffusion_for_molecules-main/qm9/data/prepare/utils.py | import os, logging
from urllib.request import urlopen
def download_data(url, outfile='', binary=False):
"""
Downloads data from a URL and returns raw data.
Parameters
----------
url : str
URL to get the data from
outfile : str, optional
Where to save the data.
binary : boo... | 1,480 | 23.278689 | 80 | py |
null | e3_diffusion_for_molecules-main/qm9/property_prediction/README.md | # E(n) Equivariant Graph Neural Networks
Official implementation (Pytorch 1.7.1) of:
**E(n) Equivariant Graph Neural Networks**
Victor Garcia Satorras, Emiel Hogeboom, Max Welling
https://arxiv.org/abs/2102.09844
<img src="models/egnn.png" width="400">
**Abstract**: This paper introduces a new model to lea... | 6,932 | 37.093407 | 710 | md |
null | e3_diffusion_for_molecules-main/qm9/property_prediction/__init__.py | 0 | 0 | 0 | py | |
null | e3_diffusion_for_molecules-main/qm9/property_prediction/main_qm9_prop.py | import sys, os
sys.path.append(os.path.abspath(os.path.join('../../')))
from qm9.property_prediction.models_property import EGNN, Naive, NumNodes
import torch
from torch import nn, optim
import argparse
from qm9.property_prediction import prop_utils
import json
from qm9 import dataset, utils
import pickle
loss_l1 = nn... | 10,043 | 44.654545 | 197 | py |
null | e3_diffusion_for_molecules-main/qm9/property_prediction/models_property.py | from .models.gcl import E_GCL, unsorted_segment_sum
import torch
from torch import nn
class E_GCL_mask(E_GCL):
"""Graph Neural Net with global state and fixed number of nodes per graph.
Args:
hidden_dim: Number of hidden units.
num_nodes: Maximum number of nodes (for self-attentive pooling... | 6,706 | 40.91875 | 233 | py |
null | e3_diffusion_for_molecules-main/qm9/property_prediction/prop_utils.py | import os
import matplotlib
matplotlib.use('Agg')
import torch
import matplotlib.pyplot as plt
def create_folders(args):
try:
os.makedirs(args.outf)
except OSError:
pass
try:
os.makedirs(args.outf + '/' + args.exp_name)
except OSError:
pass
try:
os.makedirs... | 3,051 | 28.346154 | 128 | py |
null | e3_diffusion_for_molecules-main/qm9/property_prediction/models/__init__.py | from .gcl import GCL
| 21 | 10 | 20 | py |
null | e3_diffusion_for_molecules-main/qm9/property_prediction/models/gcl.py | from torch import nn
import torch
class MLP(nn.Module):
""" a simple 4-layer MLP """
def __init__(self, nin, nout, nh):
super().__init__()
self.net = nn.Sequential(
nn.Linear(nin, nh),
nn.LeakyReLU(0.2),
nn.Linear(nh, nh),
nn.LeakyReLU(0.2),
... | 12,996 | 36.02849 | 230 | py |
Learning-Debiased-Disentangled | Learning-Debiased-Disentangled-master/CONTRIBUTING.md | ## Submitting Pull Requests
Before changes can be accepted a Contributor Licensing Agreement for [Individual](https://forms.gle/XZJvzw2JyqqJH6HN9) | [Corporate](https://forms.gle/csDh6Uxewrqxc2oc8) must be completed.
* If you are an individual writing original source code and you're sure you own the intellectual p... | 571 | 80.714286 | 190 | md |
Learning-Debiased-Disentangled | Learning-Debiased-Disentangled-master/README.md | ## Learning Debiased Representation via Disentangled Feature Augmentation (Neurips 2021, Oral): Official Project Webpage
This repository provides the official PyTorch implementation of the following paper:
> Learning Debiased Representation via Disentangled Feature Augmentation <br>
> [Jungsoo Lee](https://leebebeto.g... | 10,064 | 54 | 341 | md |
Learning-Debiased-Disentangled | Learning-Debiased-Disentangled-master/learner.py | from tqdm import tqdm
import wandb
import numpy as np
import torch
import torch.nn as nn
from torch.utils.data import DataLoader
import os
import torch.optim as optim
from data.util import get_dataset, IdxDataset
from module.loss import GeneralizedCELoss
from module.util import get_model
from util import EMA
class ... | 25,007 | 39.400646 | 161 | py |
Learning-Debiased-Disentangled | Learning-Debiased-Disentangled-master/test.py | import numpy as np
import torch
import random
from learner import Learner
import argparse
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Learning Debiased Representation via Disentangled Feature Augmentation (NeurIPS 21 Oral)')
# training
parser.add_argument("--batch_size", help=... | 3,784 | 63.152542 | 170 | py |
Learning-Debiased-Disentangled | Learning-Debiased-Disentangled-master/train.py | import numpy as np
import torch
import random
from learner import Learner
import argparse
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Learning Debiased Representation via Disentangled Feature Augmentation (NeurIPS 21 Oral)')
# training
parser.add_argument("--batch_size", help=... | 4,084 | 59.970149 | 170 | py |
Learning-Debiased-Disentangled | Learning-Debiased-Disentangled-master/util.py | '''Modified from https://github.com/alinlab/LfF/blob/master/util.py'''
import io
import torch
import numpy as np
import torch.nn as nn
class EMA:
def __init__(self, label, num_classes=None, alpha=0.9):
self.label = label.cuda()
self.alpha = alpha
self.parameter = torch.zeros(label.size(0))... | 1,178 | 35.84375 | 118 | py |
Learning-Debiased-Disentangled | Learning-Debiased-Disentangled-master/data/util.py | '''Modified from https://github.com/alinlab/LfF/blob/master/data/util.py'''
import os
import torch
from torch.utils.data.dataset import Dataset, Subset
from torchvision import transforms as T
from glob import glob
from PIL import Image
class IdxDataset(Dataset):
def __init__(self, dataset):
self.dataset =... | 9,788 | 31.73913 | 160 | py |
Learning-Debiased-Disentangled | Learning-Debiased-Disentangled-master/module/loss.py | '''From https://github.com/alinlab/LfF/blob/master/module/loss.py'''
import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
class GeneralizedCELoss(nn.Module):
def __init__(self, q=0.7):
super(GeneralizedCELoss, self).__init__()
self.q = q
... | 813 | 28.071429 | 79 | py |
Learning-Debiased-Disentangled | Learning-Debiased-Disentangled-master/module/mlp.py | ''' Modified from https://github.com/alinlab/LfF/blob/master/module/mlp.py'''
import torch
import torch.nn as nn
import torch.nn.functional as F
class MLP_DISENTANGLE(nn.Module):
def __init__(self, num_classes = 10):
super(MLP_DISENTANGLE, self).__init__()
self.feature = nn.Sequential(
... | 2,245 | 26.728395 | 77 | py |
Learning-Debiased-Disentangled | Learning-Debiased-Disentangled-master/module/resnet.py | ''' From https://github.com/alinlab/LfF/blob/master/module/resnet.py '''
"""
Properly implemented ResNet-s for CIFAR10 as described in paper [1].
The implementation and structure of this file is hugely influenced by [2]
which is implemented for ImageNet and doesn't have option A for identity.
Moreover, most of the imp... | 6,270 | 27.375566 | 78 | py |
Learning-Debiased-Disentangled | Learning-Debiased-Disentangled-master/module/util.py | ''' Modified from https://github.com/alinlab/LfF/blob/master/module/util.py '''
import torch.nn as nn
from module.resnet import resnet20
from module.mlp import *
from torchvision.models import resnet18, resnet50
def get_model(model_tag, num_classes):
if model_tag == "ResNet20":
return resnet20(num_classes... | 1,099 | 34.483871 | 79 | py |
Learning-Debiased-Disentangled | Learning-Debiased-Disentangled-master/scripts/run_bffhq_ours.sh | # BFFHQ
# 0.5pct
python train.py --dataset bffhq --exp=bffhq_0.5_ours --lr=0.0001 --percent=0.5pct --lambda_swap=0.1 --curr_step=10000 --use_lr_decay --lr_decay_step=10000 --lambda_dis_align 2. --lambda_swap_align 2. --dataset bffhq --train_ours --tensorboard --wandb | 267 | 88.333333 | 250 | sh |
Learning-Debiased-Disentangled | Learning-Debiased-Disentangled-master/scripts/run_bffhq_vanilla.sh | # BFFHQ
python train.py --dataset bffhq --exp=bffhq_0.5_vanilla --lr=0.0001 --percent=0.5pct --train_vanilla --tensorboard --wandb
| 131 | 43 | 122 | sh |
Learning-Debiased-Disentangled | Learning-Debiased-Disentangled-master/scripts/run_cifar10c_ours.sh | # Cifar10c
# 0.5pct
python train.py --dataset cifar10c --exp=cifar10c_0.5_ours --lr=0.0005 --percent=0.5pct --curr_step=10000 --lambda_swap=1 --lambda_dis_align=1 --lambda_swap_align=1 --use_lr_decay --lr_decay_step=10000 --lr_gamma=0.5 --train_ours --tensorboard --wandb
# 1pct
python train.py --dataset cifar10c --exp... | 1,037 | 78.846154 | 251 | sh |
Learning-Debiased-Disentangled | Learning-Debiased-Disentangled-master/scripts/run_cifar10c_vanilla.sh | # Cifar10c
# 0.5pct
python train.py --dataset cifar10c --exp=cifar10c_0.5_vanilla --lr=0.001 --percent=0.5pct --train_vanilla --tensorboard --wandb
# 1pct
python train.py --dataset cifar10c --exp=cifar10c_1_vanilla --lr=0.001 --percent=1pct --train_vanilla --tensorboard --wandb
# 2pct
python train.py --dataset cifar1... | 544 | 40.923077 | 127 | sh |
Learning-Debiased-Disentangled | Learning-Debiased-Disentangled-master/scripts/run_cmnist_ours.sh | # CMNIST
# 0.5pct
python train.py --dataset cmnist --exp=cmnist_0.5_ours --lr=0.01 --percent=0.5pct --curr_step=10000 --lambda_swap=1 --lambda_dis_align=10 --lambda_swap_align=10 --use_lr_decay --lr_decay_step=10000 --lr_gamma=0.5 --train_ours --tensorboard --wandb
# 1pct
python train.py --dataset cmnist --exp=cmnist_... | 1,024 | 84.416667 | 247 | sh |
Learning-Debiased-Disentangled | Learning-Debiased-Disentangled-master/scripts/run_cmnist_vanilla.sh | # CMNIST
# 0.5pct
python train.py --dataset cmnist --exp=cmnist_0.5_vanilla --lr=0.01 --percent=0.5pct --train_vanilla --tensorboard --wandb
# 1pct
python train.py --dataset cmnist --exp=cmnist_1_vanilla --lr=0.01 --percent=1pct --train_vanilla --tensorboard --wandb
# 2pct
python train.py --dataset cmnist --exp=cmnis... | 522 | 39.230769 | 122 | sh |
null | MonotonicNetworks-main/README.md | # Table of Contents
- [Lipschitz Monotonic Networks](#lipschitz-monotonic-networks)
- [Installation](#installation)
- [Requirements](#requirements)
- [Usage](#usage)
- [Examples](#examples)
- [Monotonicity](#monotonicity)
- [Robustness](#robustness)
- [Lipschitz NNs can describe arbitrarily complex boundar... | 6,693 | 63.990291 | 623 | md |
null | MonotonicNetworks-main/setup.py | from setuptools import setup
setup(
name="monotonicnetworks",
version="1.5.0",
packages=["monotonicnetworks"],
url="",
license="MIT",
author="Ouail Kitouni, Niklas Nolte",
author_email="kitouni@mit.edu, nolte@meta.com",
description=(
"Pytorch implementation of constrained weight... | 411 | 24.75 | 85 | py |
null | MonotonicNetworks-main/Examples/flower.py | import numpy as np
from matplotlib import pyplot as plt
import torch
from tqdm import tqdm
from torch.utils.data import DataLoader, TensorDataset
from monotonicnetworks import GroupSort, direct_norm
from argparse import ArgumentParser
from pathlib import Path
plt.style.use(Path(__file__).parent / "mpl-config")
torch.... | 5,117 | 30.018182 | 84 | py |
null | MonotonicNetworks-main/monotonicnetworks/LipschitzMonotonicNetwork.py | import torch
import typing as T
from .functional import direct_norm
import warnings
from torch.nn import Module, Parameter, Linear
class MonotonicWrapper(Module):
def __init__(
self,
lipschitz_module: Module, # Must already be lipschitz
lipschitz_const: float = 1.0,
monotonic_cons... | 8,767 | 41.770732 | 100 | py |
null | MonotonicNetworks-main/monotonicnetworks/__init__.py | from .functional import direct_norm, project_norm, get_normed_weights
from .LipschitzMonotonicNetwork import (
MonotonicWrapper,
MonotonicLayer,
LipschitzLinear,
RMSNorm,
SigmaNet
)
from .group import GroupSort
__all__ = [
"direct_norm",
"project_norm",
"MonotonicWrapper",
"GroupSor... | 428 | 18.5 | 69 | py |
null | MonotonicNetworks-main/monotonicnetworks/functional.py | from torch import nn
import torch
from torch.nn.utils.parametrize import register_parametrization
import typing as t
kinds = [
"one", # |W|_1 constraint
"inf", # |W|_inf constraint
"one-inf", # |W|_1,inf constraint
"two-inf", # |W|_2,inf constraint
]
def direct_norm(
layer: nn.Linear,
kin... | 6,251 | 36.890909 | 112 | py |
null | MonotonicNetworks-main/monotonicnetworks/group.py | import torch
class GroupSort(torch.nn.Module):
def __init__(self, n_groups: int, axis: int = -1):
super(GroupSort, self).__init__()
self.n_groups = n_groups
self.axis = axis
def forward(self, x: torch.Tensor):
return group_sort(x, self.n_groups, self.axis)
def extra_repr(... | 1,235 | 28.428571 | 96 | py |
null | MonotonicNetworks-main/monotonicnetworks/tests.py | # Bug fix for project_norm
import unittest
from .functional import direct_norm, project_norm
from .group import GroupSort
from .LipschitzMonotonicNetwork import LipschitzLinear
import torch
class TestNorms(unittest.TestCase):
def test_no_norm(self):
loss = train(lambda x, **kwargs: x)
self.assertA... | 1,362 | 26.26 | 72 | py |
null | Fast-beam-alignment-main/README.md | # Fast-beam-alignment
Code for the paper "Fast Beam Alignment via Pure Exploration in Multi-armed Bandits"
| 107 | 35 | 84 | md |
stylegan2 | stylegan2-master/README.md | ## StyleGAN2 — Official TensorFlow Implementation

**Analyzing and Improving the Image Quality of StyleGAN**<br>
Tero Karras, Samuli Laine, Miika Aittala, Janne Hellsten, Jaakko Lehtinen, Timo Aila<br>
Paper: http://arxiv.org/abs/1912.04958<br>
Video: https:... | 14,794 | 65.945701 | 1,098 | md |
stylegan2 | stylegan2-master/dataset_tool.py | # Copyright (c) 2019, NVIDIA Corporation. All rights reserved.
#
# This work is made available under the Nvidia Source Code License-NC.
# To view a copy of this license, visit
# https://nvlabs.github.io/stylegan2/license.html
"""Tool for creating multi-resolution TFRecords datasets."""
# pylint: disable=too-many-line... | 30,282 | 45.950388 | 153 | py |
stylegan2 | stylegan2-master/pretrained_networks.py | # Copyright (c) 2019, NVIDIA Corporation. All rights reserved.
#
# This work is made available under the Nvidia Source Code License-NC.
# To view a copy of this license, visit
# https://nvlabs.github.io/stylegan2/license.html
"""List of pre-trained StyleGAN2 networks located on Google Drive."""
import pickle
import d... | 7,521 | 91.864198 | 181 | py |
stylegan2 | stylegan2-master/projector.py | # Copyright (c) 2019, NVIDIA Corporation. All rights reserved.
#
# This work is made available under the Nvidia Source Code License-NC.
# To view a copy of this license, visit
# https://nvlabs.github.io/stylegan2/license.html
import numpy as np
import tensorflow as tf
import dnnlib
import dnnlib.tflib as tflib
from t... | 8,975 | 42.362319 | 150 | py |
stylegan2 | stylegan2-master/run_generator.py | # Copyright (c) 2019, NVIDIA Corporation. All rights reserved.
#
# This work is made available under the Nvidia Source Code License-NC.
# To view a copy of this license, visit
# https://nvlabs.github.io/stylegan2/license.html
import argparse
import numpy as np
import PIL.Image
import dnnlib
import dnnlib.tflib as tfli... | 8,245 | 47.222222 | 172 | py |
stylegan2 | stylegan2-master/run_metrics.py | # Copyright (c) 2019, NVIDIA Corporation. All rights reserved.
#
# This work is made available under the Nvidia Source Code License-NC.
# To view a copy of this license, visit
# https://nvlabs.github.io/stylegan2/license.html
import argparse
import os
import sys
import dnnlib
import dnnlib.tflib as tflib
import pret... | 3,447 | 38.632184 | 156 | py |
stylegan2 | stylegan2-master/run_projector.py | # Copyright (c) 2019, NVIDIA Corporation. All rights reserved.
#
# This work is made available under the Nvidia Source Code License-NC.
# To view a copy of this license, visit
# https://nvlabs.github.io/stylegan2/license.html
import argparse
import numpy as np
import dnnlib
import dnnlib.tflib as tflib
import re
impor... | 6,963 | 45.738255 | 160 | py |
stylegan2 | stylegan2-master/run_training.py | # Copyright (c) 2019, NVIDIA Corporation. All rights reserved.
#
# This work is made available under the Nvidia Source Code License-NC.
# To view a copy of this license, visit
# https://nvlabs.github.io/stylegan2/license.html
import argparse
import copy
import os
import sys
import dnnlib
from dnnlib import EasyDict
... | 8,473 | 42.234694 | 153 | py |
stylegan2 | stylegan2-master/dnnlib/__init__.py | # Copyright (c) 2019, NVIDIA Corporation. All rights reserved.
#
# This work is made available under the Nvidia Source Code License-NC.
# To view a copy of this license, visit
# https://nvlabs.github.io/stylegan2/license.html
from . import submission
from .submission.run_context import RunContext
from .submission.su... | 774 | 34.227273 | 126 | py |
stylegan2 | stylegan2-master/dnnlib/util.py | # Copyright (c) 2019, NVIDIA Corporation. All rights reserved.
#
# This work is made available under the Nvidia Source Code License-NC.
# To view a copy of this license, visit
# https://nvlabs.github.io/stylegan2/license.html
"""Miscellaneous utility classes and functions."""
import ctypes
import fnmatch
import impo... | 13,914 | 32.856448 | 151 | py |
stylegan2 | stylegan2-master/dnnlib/submission/__init__.py | # Copyright (c) 2019, NVIDIA Corporation. All rights reserved.
#
# This work is made available under the Nvidia Source Code License-NC.
# To view a copy of this license, visit
# https://nvlabs.github.io/stylegan2/license.html
from . import run_context
from . import submit
| 274 | 29.555556 | 70 | py |
stylegan2 | stylegan2-master/dnnlib/submission/run_context.py | # Copyright (c) 2019, NVIDIA Corporation. All rights reserved.
#
# This work is made available under the Nvidia Source Code License-NC.
# To view a copy of this license, visit
# https://nvlabs.github.io/stylegan2/license.html
"""Helpers for managing the run/training loop."""
import datetime
import json
import os
impo... | 4,245 | 37.252252 | 162 | py |
stylegan2 | stylegan2-master/dnnlib/submission/submit.py | # Copyright (c) 2019, NVIDIA Corporation. All rights reserved.
#
# This work is made available under the Nvidia Source Code License-NC.
# To view a copy of this license, visit
# https://nvlabs.github.io/stylegan2/license.html
"""Submit a function to be run either locally or in a computing cluster."""
import copy
impo... | 13,502 | 38.252907 | 238 | py |
stylegan2 | stylegan2-master/dnnlib/submission/internal/__init__.py | # Copyright (c) 2019, NVIDIA Corporation. All rights reserved.
#
# This work is made available under the Nvidia Source Code License-NC.
# To view a copy of this license, visit
# https://nvlabs.github.io/stylegan2/license.html
from . import local
| 247 | 30 | 70 | py |
stylegan2 | stylegan2-master/dnnlib/submission/internal/local.py | # Copyright (c) 2019, NVIDIA Corporation. All rights reserved.
#
# This work is made available under the Nvidia Source Code License-NC.
# To view a copy of this license, visit
# https://nvlabs.github.io/stylegan2/license.html
class TargetOptions():
def __init__(self):
self.do_not_copy_source_files = False
... | 769 | 32.478261 | 80 | py |
stylegan2 | stylegan2-master/dnnlib/tflib/__init__.py | # Copyright (c) 2019, NVIDIA Corporation. All rights reserved.
#
# This work is made available under the Nvidia Source Code License-NC.
# To view a copy of this license, visit
# https://nvlabs.github.io/stylegan2/license.html
from . import autosummary
from . import network
from . import optimizer
from . import tfutil
... | 467 | 23.631579 | 70 | py |
stylegan2 | stylegan2-master/dnnlib/tflib/autosummary.py | # Copyright (c) 2019, NVIDIA Corporation. All rights reserved.
#
# This work is made available under the Nvidia Source Code License-NC.
# To view a copy of this license, visit
# https://nvlabs.github.io/stylegan2/license.html
"""Helper for adding automatically tracked values to Tensorboard.
Autosummary creates an ide... | 8,038 | 40.869792 | 135 | py |
stylegan2 | stylegan2-master/dnnlib/tflib/custom_ops.py | # Copyright (c) 2019, NVIDIA Corporation. All rights reserved.
#
# This work is made available under the Nvidia Source Code License-NC.
# To view a copy of this license, visit
# https://nvlabs.github.io/stylegan2/license.html
"""TensorFlow custom ops builder.
"""
import os
import re
import uuid
import hashlib
import ... | 7,223 | 41.494118 | 153 | py |
stylegan2 | stylegan2-master/dnnlib/tflib/network.py | # Copyright (c) 2019, NVIDIA Corporation. All rights reserved.
#
# This work is made available under the Nvidia Source Code License-NC.
# To view a copy of this license, visit
# https://nvlabs.github.io/stylegan2/license.html
"""Helper for managing networks."""
import types
import inspect
import re
import uuid
import... | 29,982 | 49.732657 | 165 | py |
stylegan2 | stylegan2-master/dnnlib/tflib/optimizer.py | # Copyright (c) 2019, NVIDIA Corporation. All rights reserved.
#
# This work is made available under the Nvidia Source Code License-NC.
# To view a copy of this license, visit
# https://nvlabs.github.io/stylegan2/license.html
"""Helper wrapper for a Tensorflow optimizer."""
import platform
import numpy as np
import t... | 20,298 | 53.714286 | 155 | py |
stylegan2 | stylegan2-master/dnnlib/tflib/tfutil.py | # Copyright (c) 2019, NVIDIA Corporation. All rights reserved.
#
# This work is made available under the Nvidia Source Code License-NC.
# To view a copy of this license, visit
# https://nvlabs.github.io/stylegan2/license.html
"""Miscellaneous helper utils for Tensorflow."""
import os
import numpy as np
import tensorf... | 9,675 | 37.245059 | 173 | py |
stylegan2 | stylegan2-master/dnnlib/tflib/ops/__init__.py | # Copyright (c) 2019, NVIDIA Corporation. All rights reserved.
#
# This work is made available under the Nvidia Source Code License-NC.
# To view a copy of this license, visit
# https://nvlabs.github.io/stylegan2/license.html
# empty
| 235 | 28.5 | 70 | py |