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 |
|---|---|---|---|---|---|---|
FL-MRCM | FL-MRCM-main/data/volume_sampler.py | import torch
import numpy as np
from torch.utils.data import Sampler
import torch.distributed as dist
class VolumeSampler(Sampler):
"""
Based on pytorch DistributedSampler, the difference is that all instances from the same
volume need to go to the same node. Dataset example is a list of tuples (f... | 1,738 | 30.618182 | 105 | py |
FL-MRCM | FL-MRCM-main/data/mri_data.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 pathlib
import random
import numpy as np
import h5py
from torch.utils.data import Dataset
from data import transforms
import torch
... | 6,487 | 40.063291 | 116 | py |
FL-MRCM | FL-MRCM-main/data/subsample.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
def create_mask_for_mask_type(mask_type_str, center_fractions, accelerations):
if mask_type_str == 'ran... | 7,422 | 42.409357 | 112 | py |
FL-MRCM | FL-MRCM-main/data/__init__.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @python: 3.6
| 61 | 14.5 | 23 | py |
FL-MRCM | FL-MRCM-main/data/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.
"""
import numpy as np
import torch
def to_tensor(data):
"""
Convert numpy array to PyTorch tensor. For complex arrays, the real and im... | 11,406 | 28.705729 | 115 | py |
pldi19-equivalence-checker | pldi19-equivalence-checker-master/tools/scripts/completion_generator.py | #!/usr/bin/python
# ------------------------------------------------------------------------------
#
# Automatic generation of a completion function for stoke for zsh.
# Running this file will produce bin/_stoke, which can be used by zsh. If the
# env variable ZSH_COMPLETION_DIR points to a directory, then _stoke is ... | 11,939 | 28.121951 | 142 | py |
pldi19-equivalence-checker | pldi19-equivalence-checker-master/src/ext/gtest-1.7.0/xcode/Scripts/versiongenerate.py | #!/usr/bin/env python
#
# Copyright 2008, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list... | 4,536 | 43.920792 | 80 | py |
pldi19-equivalence-checker | pldi19-equivalence-checker-master/src/ext/gtest-1.7.0/test/gtest_list_tests_unittest.py | #!/usr/bin/env python
#
# Copyright 2006, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list... | 6,515 | 30.326923 | 79 | py |
pldi19-equivalence-checker | pldi19-equivalence-checker-master/src/ext/gtest-1.7.0/test/gtest_throw_on_failure_test.py | #!/usr/bin/env python
#
# Copyright 2009, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list... | 5,766 | 32.52907 | 79 | py |
pldi19-equivalence-checker | pldi19-equivalence-checker-master/src/ext/gtest-1.7.0/test/gtest_xml_outfiles_test.py | #!/usr/bin/env python
#
# Copyright 2008, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list... | 5,340 | 39.157895 | 140 | py |
pldi19-equivalence-checker | pldi19-equivalence-checker-master/src/ext/gtest-1.7.0/test/gtest_filter_unittest.py | #!/usr/bin/env python
#
# Copyright 2005 Google Inc. All Rights Reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of... | 21,261 | 32.536278 | 80 | py |
pldi19-equivalence-checker | pldi19-equivalence-checker-master/src/ext/gtest-1.7.0/test/gtest_xml_test_utils.py | #!/usr/bin/env python
#
# Copyright 2006, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list... | 8,876 | 44.523077 | 79 | py |
pldi19-equivalence-checker | pldi19-equivalence-checker-master/src/ext/gtest-1.7.0/test/gtest_test_utils.py | #!/usr/bin/env python
#
# Copyright 2006, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list... | 10,812 | 32.685358 | 79 | py |
pldi19-equivalence-checker | pldi19-equivalence-checker-master/src/ext/gtest-1.7.0/test/gtest_shuffle_test.py | #!/usr/bin/env python
#
# Copyright 2009 Google Inc. All Rights Reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of... | 12,549 | 37.496933 | 79 | py |
pldi19-equivalence-checker | pldi19-equivalence-checker-master/src/ext/gtest-1.7.0/test/gtest_env_var_test.py | #!/usr/bin/env python
#
# Copyright 2008, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list... | 3,487 | 32.538462 | 79 | py |
pldi19-equivalence-checker | pldi19-equivalence-checker-master/src/ext/gtest-1.7.0/test/gtest_help_test.py | #!/usr/bin/env python
#
# Copyright 2009, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list... | 5,856 | 32.855491 | 75 | py |
pldi19-equivalence-checker | pldi19-equivalence-checker-master/src/ext/gtest-1.7.0/test/gtest_break_on_failure_unittest.py | #!/usr/bin/env python
#
# Copyright 2006, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list... | 7,339 | 33.460094 | 79 | py |
pldi19-equivalence-checker | pldi19-equivalence-checker-master/src/ext/gtest-1.7.0/test/gtest_output_test.py | #!/usr/bin/env python
#
# Copyright 2008, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list... | 12,005 | 34.732143 | 79 | py |
pldi19-equivalence-checker | pldi19-equivalence-checker-master/src/ext/gtest-1.7.0/test/gtest_catch_exceptions_test.py | #!/usr/bin/env python
#
# Copyright 2010 Google Inc. All Rights Reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list o... | 9,901 | 40.605042 | 78 | py |
pldi19-equivalence-checker | pldi19-equivalence-checker-master/src/ext/gtest-1.7.0/test/gtest_uninitialized_test.py | #!/usr/bin/env python
#
# Copyright 2008, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list... | 2,480 | 33.943662 | 77 | py |
pldi19-equivalence-checker | pldi19-equivalence-checker-master/src/ext/gtest-1.7.0/test/gtest_color_test.py | #!/usr/bin/env python
#
# Copyright 2008, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list... | 4,911 | 36.496183 | 76 | py |
pldi19-equivalence-checker | pldi19-equivalence-checker-master/src/ext/gtest-1.7.0/test/gtest_xml_output_unittest.py | #!/usr/bin/env python
#
# Copyright 2006, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list... | 14,580 | 46.340909 | 225 | py |
pldi19-equivalence-checker | pldi19-equivalence-checker-master/src/ext/gtest-1.7.0/scripts/fuse_gtest_files.py | #!/usr/bin/env python
#
# Copyright 2009, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list... | 8,813 | 34.115538 | 78 | py |
pldi19-equivalence-checker | pldi19-equivalence-checker-master/src/ext/gtest-1.7.0/scripts/pump.py | #!/usr/bin/env python
#
# Copyright 2008, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list... | 23,673 | 26.656542 | 80 | py |
pldi19-equivalence-checker | pldi19-equivalence-checker-master/src/ext/gtest-1.7.0/scripts/gen_gtest_pred_impl.py | #!/usr/bin/env python
#
# Copyright 2006, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list... | 21,986 | 29.077975 | 76 | py |
pldi19-equivalence-checker | pldi19-equivalence-checker-master/bin/sage_harness.sage.py |
# This file was *autogenerated* from the file /home/equivalence/equivalence-checker/bin/sage_harness.sage
from sage.all_cmdline import * # import sage library
import fileinput
import sys
for line in fileinput.input():
execfile(line.strip())
print "OK"
sys.stdout.flush()
| 281 | 19.142857 | 105 | py |
3D-Pattern-Lock | 3D-Pattern-Lock-master/countPatterns/countpatterns2D.py | #!/usr/bin/env python
# 1 2 3
# 4 5 6
# 7 8 9
positions = "123456789"
posmap = {};
for i, c in enumerate(positions):
posmap[c] = [i%3, int(i/3)%3]
def posat(xy):
[x,y] = xy
return positions[x + y*3]
def posflipX(xy):
[x,y] = xy
return [2-x,y]
def posflipY(xy):
[x,y] = xy
return [x,2-y... | 1,155 | 17.645161 | 57 | py |
3D-Pattern-Lock | 3D-Pattern-Lock-master/countPatterns/countpatterns3D.py | #!/usr/bin/env python
# 1 2 3
# 4 5 6
# 7 8 9
# A B C
# D E F
# G H I
# J K L
# M N O
# P Q R
positions = "123456789ABCDEFGHIJKLMNOPQR"
posmap = {};
for i, c in enumerate(positions):
posmap[c] = [i%3, int(i/3)%3, int(i/9)]
def posat(xyz):
[x,y,z] = xyz
return positions[x + y*3 + z*9]
def posflipX(xy... | 2,150 | 21.175258 | 57 | py |
ceb | ceb-master/examples/evaluate_postgres_estimates.py | import sys
sys.path.append(".")
from query_representation.query import *
from losses.losses import *
import glob
import argparse
import random
def main():
qreps = []
preds = []
fns = list(glob.glob(args.query_dir + "/*"))
all_qfns = []
for qi,qdir in enumerate(fns):
template_name = os.pat... | 1,755 | 30.357143 | 77 | py |
ceb | ceb-master/query_representation/query.py | import networkx as nx
from networkx.readwrite import json_graph
from utils.utils import *
import time
import itertools
import json
import pdb
import pickle
def get_subset_cache_name(sql):
return str(deterministic_hash(sql)[0:5])
def parse_sql(sql, user, db_name, db_host, port, pwd, timeout=False,
compute... | 4,703 | 28.584906 | 80 | py |
ceb | ceb-master/tests/test_installation.py | import sys
sys.path.append(".")
from query_representation.query import *
from losses.losses import *
import glob
import random
query_dir = "./queries/imdb/"
test_queries = ["4a/4a100.pkl"]
num_per_template=10
def test_load():
for q in test_queries:
qfn = query_dir + q
qrep = load_qrep(qfn)
... | 1,047 | 21.297872 | 51 | py |
ceb | ceb-master/utils/utils.py | import sqlparse
from sqlparse.sql import IdentifierList, Identifier
from sqlparse.tokens import Keyword, DML
from moz_sql_parser import parse
import time
from networkx.drawing.nx_agraph import graphviz_layout, to_agraph
from networkx.algorithms import bipartite
import networkx as nx
import itertools
import hashlib
impo... | 27,656 | 31.309579 | 88 | py |
ceb | ceb-master/query_gen/query_generator.py | # from db_utils.utils import *
from utils.utils import *
import pdb
from nltk.tokenize import word_tokenize
import pygtrie
import klepto
import random
ILIKE_PRED_FMT = "'%{ILIKE_PRED}%'"
class QueryGenerator():
'''
Generates sql queries based on a template.
TODO: explain rules etc.
'''
def __init__... | 18,250 | 43.406326 | 100 | py |
ceb | ceb-master/query_gen/gen_queries.py | import argparse
import psycopg2 as pg
import sys
sys.path.append(".")
import pdb
import random
import klepto
from multiprocessing import Pool
import multiprocessing
import toml
# from db_utils.query_storage import *
from utils.utils import *
import json
import pickle
# from sql_rep.query import parse_sql
# from sql_re... | 3,696 | 30.598291 | 79 | py |
ceb | ceb-master/query_gen/__init__.py | 0 | 0 | 0 | py | |
ceb | ceb-master/losses/losses.py | import numpy as np
import pdb
from losses.plan_losses import PPC, PlanCost
from utils.utils import deterministic_hash,make_dir
import multiprocessing as mp
import random
from collections import defaultdict
import pandas as pd
import networkx as nx
import datetime
import os
def fix_query(query):
# these conditions... | 6,756 | 31.960976 | 79 | py |
ceb | ceb-master/losses/plan_losses.py | import psycopg2 as pg
import getpass
import numpy as np
from utils.utils import *
from .cost_model import *
import multiprocessing as mp
import math
import pdb
import klepto
import copy
SOURCE_NODE = tuple(["SOURCE"])
PG_HINT_CMNT_TMP = '''/*+ {COMMENT} */'''
PG_HINT_JOIN_TMP = "{JOIN_TYPE} ({TABLES}) "
PG_HINT_CARD_... | 17,585 | 35.945378 | 81 | py |
ceb | ceb-master/losses/__init__.py | 0 | 0 | 0 | py | |
ceb | ceb-master/losses/cost_model.py | import pdb
NILJ_CONSTANT = 0.001
def add_single_node_edges(subset_graph, source):
subset_graph.add_node(source)
subset_graph.nodes()[source]["cardinality"] = {}
subset_graph.nodes()[source]["cardinality"]["actual"] = 1.0
for node in subset_graph.nodes():
if len(node) != 1:
contin... | 4,420 | 31.036232 | 78 | py |
ceb | ceb-master/losses/get_runtimes.py | import pickle
import argparse
import glob
import pdb
import psycopg2 as pg
import time
import subprocess as sp
import os
import pandas as pd
from collections import defaultdict
import sys
sys.path.append(".")
from utils.utils import *
# from losses.cost_model import *
import pdb
TIMEOUT_CONSTANT = 909
RERUN_TIMEOUTS =... | 5,922 | 31.905556 | 90 | py |
HabitatDyn | HabitatDyn-main/metric_cal.py | import argparse
import logging
import os
import numpy as np
import torch
import torch.utils.data.dataloader as dataloader
from PIL import Image
from torch.utils.data import Dataset
from torch.utils.data.dataset import Dataset
from tqdm import tqdm
from utils.common import safe_mkdir
from utils.meter import AverageVal... | 9,689 | 36.55814 | 101 | py |
HabitatDyn | HabitatDyn-main/dist_metric_cal.py | import argparse
import logging
import math
import os
import numpy as np
from utils.common import safe_mkdir
# TODO add sub-drectory for each exp
# TODO argparser for detect ranger
parser = argparse.ArgumentParser(
description='Calculate metrics for distance estimation results')
parser.add_argument('--data_path',... | 4,480 | 33.736434 | 168 | py |
HabitatDyn | HabitatDyn-main/dist_cal.py | import json
import logging
import os
import cv2
import argparse
import matplotlib.pyplot as plt
import numpy as np
import scipy.spatial.distance as sci_dis
import torch
import yaml
from sklearn.cluster import DBSCAN
from sklearn.neighbors import LocalOutlierFactor
from tqdm import tqdm
import utils.distance_estimatio... | 22,013 | 47.170678 | 183 | py |
HabitatDyn | HabitatDyn-main/config/__init__.py | 0 | 0 | 0 | py | |
HabitatDyn | HabitatDyn-main/config/default.py | #!/usr/bin/env python3
class SEMANTIC_ANTICIPATOR:
def __init__(self, raw):
self.type = raw['type']
self.resnet_type = raw['resnet_type']
self.unet_nsf = raw['unet_nsf']
self.map_scale = raw['map_scale']
self.nclasses = raw['nclasses']
self.freeze_features = raw['fre... | 1,236 | 36.484848 | 85 | py |
HabitatDyn | HabitatDyn-main/utils/distance_estimation.py | import numpy as np
import cv2
from einops import asnumpy
from utils.geometry_utils import quaternion_from_two_vectors
import quaternion
class GTEgoMap():
r"""Estimates the top-down occupancy based on current depth-map.
Args:
sim: reference to the simulator for calculating task observations.
co... | 6,111 | 34.952941 | 154 | py |
HabitatDyn | HabitatDyn-main/utils/create_training_data.py | import math
import numpy as np
from scipy.spatial import ConvexHull
from utils.geometry_utils import (
quaternion_from_coeff,
compute_heading_from_quaternion,quaternion_xyzw_to_wxyz,
compute_quaternion_from_heading,
quaternion_rotate_vector
)
def rectangle_coordinates(center:li... | 5,616 | 36.952703 | 142 | py |
HabitatDyn | HabitatDyn-main/utils/geometry_utils.py | #!/usr/bin/env python3
from typing import List, Tuple, Union
import math
import quaternion
import numpy as np
EPSILON = 1e-8
def angle_between_quaternions(q1: np.quaternion, q2: np.quaternion) -> float:
r"""Returns the angle (in radians) between two quaternions. This angle will
always be positive.
"""
... | 6,370 | 29.483254 | 93 | py |
HabitatDyn | HabitatDyn-main/utils/common.py | import pathlib
import numpy as np
import math
import numbers
import torch
from torch import nn
from torch.nn import functional as F
def safe_mkdir(path):
try:
pathlib.Path(path).mkdir(parents=True, exist_ok=True)
except:
pass
def intersect2d(A,B):
'''
calculate the intersection of two... | 3,632 | 32.330275 | 86 | py |
HabitatDyn | HabitatDyn-main/utils/metrics.py | import torch
import torch.nn.functional as F
import torch.nn as nn
def iou(pred_mask, gt_mask):
"""Calculates the IoU of two masks.
Args:
pred_mask: A torch.Tensor of shape (batch_size, height, width).
gt_mask: A torch.Tensor of shape (batch_size, height, width).
Returns:
A torch.Tensor of shape (... | 1,792 | 27.015625 | 87 | py |
HabitatDyn | HabitatDyn-main/utils/__init__.py | #!/usr/bin/env python3 | 22 | 22 | 22 | py |
HabitatDyn | HabitatDyn-main/utils/meter.py | import numpy as np
class Meter(object):
"""Meters provide a way to keep track of important statistics in an online manner.
This class is abstract, but provides a standard interface for all meters to follow.
"""
def reset(self):
"""Reset the meter to default settings."""
pass
def ... | 1,655 | 26.147541 | 87 | py |
HabitatDyn | HabitatDyn-main/utils/display.py | from PIL import Image
import matplotlib.pyplot as plt
import numpy as np
def makr_robot_loc(map_size):
plt.scatter(map_size/2, 5, color="b", s=1000) | 153 | 24.666667 | 49 | py |
FastJTNNpy3 | FastJTNNpy3-master/fast_bo/gen_latent.py | import sys
sys.path.append('../')
import torch
import torch.nn as nn
from optparse import OptionParser
from tqdm import tqdm
import rdkit
from rdkit.Chem import Descriptors
from rdkit.Chem import MolFromSmiles, MolToSmiles
from rdkit.Chem import rdmolops
import numpy as np
from fast_jtnn import *
from fast_jtnn impor... | 4,431 | 32.074627 | 78 | py |
FastJTNNpy3 | FastJTNNpy3-master/fast_bo/__init__.py | 0 | 0 | 0 | py | |
FastJTNNpy3 | FastJTNNpy3-master/fast_bo/run_bo.py | import sys
sys.path.append('../')
import pickle
import gzip
import scipy.stats as sps
import numpy as np
import os
import rdkit
from rdkit.Chem import MolFromSmiles, MolToSmiles
from rdkit.Chem import Descriptors
import torch
import torch.nn as nn
from fast_jtnn import create_var, JTNNVAE, Vocab, sascorer
from fast_jtn... | 8,400 | 32.738956 | 79 | py |
FastJTNNpy3 | FastJTNNpy3-master/fast_jtnn/gauss.py |
import theano
import theano.tensor as T
import numpy as np
from scipy.spatial.distance import cdist
def casting(x):
return np.array(x).astype(theano.config.floatX)
def compute_kernel(lls, lsf, x, z):
ls = T.exp(lls)
sf = T.exp(lsf)
if x.ndim == 1:
x = x[ None, : ]
if z.ndim == 1:
... | 4,638 | 31.440559 | 123 | py |
FastJTNNpy3 | FastJTNNpy3-master/fast_jtnn/jtnn_enc.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from collections import deque
from .mol_tree import Vocab, MolTree
from .nnutils import create_var, index_select_ND
class JTNNEncoder(nn.Module):
def __init__(self, hidden_size, depth, embedding):
super(JTNNEncoder, self).__init__()
... | 4,473 | 32.893939 | 80 | py |
FastJTNNpy3 | FastJTNNpy3-master/fast_jtnn/datautils.py | import torch
from torch.utils.data import Dataset, DataLoader
from .mol_tree import MolTree
import numpy as np
from .jtnn_enc import JTNNEncoder
from .mpn import MPN
from .jtmpn import JTMPN
import pickle as pickle
import os, random
class PairTreeFolder(object):
def __init__(self, data_folder, vocab, batch_size, ... | 4,697 | 32.798561 | 131 | py |
FastJTNNpy3 | FastJTNNpy3-master/fast_jtnn/nnutils.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
def create_var(tensor, requires_grad=None):
if requires_grad is None:
return Variable(tensor).cuda()
else:
return Variable(tensor, requires_grad=requires_grad).cuda()
def index_select_ND(sour... | 2,042 | 29.492537 | 67 | py |
FastJTNNpy3 | FastJTNNpy3-master/fast_jtnn/mpn.py | import torch
import torch.nn as nn
import rdkit.Chem as Chem
import torch.nn.functional as F
from .nnutils import *
from .chemutils import get_mol
ELEM_LIST = ['C', 'N', 'O', 'S', 'F', 'Si', 'P', 'Cl', 'Br', 'Mg', 'Na', 'Ca', 'Fe', 'Al', 'I', 'B', 'K', 'Se', 'Zn', 'H', 'Cu', 'Mn', 'unknown']
ATOM_FDIM = len(ELEM_LIST... | 4,469 | 34.47619 | 171 | py |
FastJTNNpy3 | FastJTNNpy3-master/fast_jtnn/jtnn_vae.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from .mol_tree import Vocab, MolTree
from .nnutils import create_var, flatten_tensor, avg_pool
from .jtnn_enc import JTNNEncoder
from .jtnn_dec import JTNNDecoder
from .mpn import MPN
from .jtmpn import JTMPN
from .datautils import tensorize
from .chem... | 10,015 | 43.318584 | 172 | py |
FastJTNNpy3 | FastJTNNpy3-master/fast_jtnn/sparse_gp_theano_internal.py |
import theano
import theano.tensor as T
import numpy as np
from .gauss import *
from theano.tensor.slinalg import Cholesky as MatrixChol
import math
def n_pdf(x):
return 1.0 / T.sqrt(2 * math.pi) * T.exp(-0.5 * x**2)
def log_n_pdf(x):
return -0.5 * T.log(2 * math.pi) - 0.5 * x**2
def n_cdf(x):
retur... | 15,513 | 44.899408 | 144 | py |
FastJTNNpy3 | FastJTNNpy3-master/fast_jtnn/mol_tree.py | import rdkit
import rdkit.Chem as Chem
from .chemutils import get_clique_mol, tree_decomp, get_mol, get_smiles, set_atommap, enum_assemble, decode_stereo
from .vocab import *
import sys
import argparse
class MolTreeNode(object):
def __init__(self, smiles, clique=[]):
self.smiles = smiles
self.mol ... | 4,853 | 32.020408 | 114 | py |
FastJTNNpy3 | FastJTNNpy3-master/fast_jtnn/vocab.py | import rdkit
import rdkit.Chem as Chem
import copy
def get_slots(smiles):
mol = Chem.MolFromSmiles(smiles)
return [(atom.GetSymbol(), atom.GetFormalCharge(), atom.GetTotalNumHs()) for atom in mol.GetAtoms()]
class Vocab(object):
benzynes = ['C1=CC=CC=C1', 'C1=CC=NC=C1', 'C1=CC=NN=C1', 'C1=CN=CC=N1', 'C1=C... | 1,470 | 44.96875 | 341 | py |
FastJTNNpy3 | FastJTNNpy3-master/fast_jtnn/jtprop_vae.py | import torch
import torch.nn as nn
from .mol_tree import Vocab, MolTree
from .nnutils import create_var
from .jtnn_enc import JTNNEncoder
from .jtnn_dec import JTNNDecoder
from .mpn import MPN, mol2graph
from .jtmpn import JTMPN
from .chemutils import enum_assemble, set_atommap, copy_edit_mol, attach_mols, atom_equal,... | 14,781 | 40.757062 | 144 | py |
FastJTNNpy3 | FastJTNNpy3-master/fast_jtnn/jtmpn.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from .nnutils import create_var, index_select_ND
from .chemutils import get_mol
import rdkit.Chem as Chem
ELEM_LIST = ['C', 'N', 'O', 'S', 'F', 'Si', 'P', 'Cl', 'Br', 'Mg', 'Na', 'Ca', 'Fe', 'Al', 'I', 'B', 'K', 'Se', 'Zn', 'H', 'Cu', 'Mn', 'unknown']
... | 5,387 | 37.76259 | 184 | py |
FastJTNNpy3 | FastJTNNpy3-master/fast_jtnn/sparse_gp.py | ##
# This class represents a node within the network
#
import theano
import theano.tensor as T
from .sparse_gp_theano_internal import *
import scipy.stats as sps
import scipy.optimize as spo
import numpy as np
import sys
import time
from tqdm import tqdm
def casting(x):
return np.array(x).astype(theano.config.floa... | 14,519 | 42.473054 | 140 | py |
FastJTNNpy3 | FastJTNNpy3-master/fast_jtnn/jtnn_dec.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from .mol_tree import Vocab, MolTree, MolTreeNode
from .nnutils import create_var, GRU
from .chemutils import enum_assemble, set_atommap
import copy
MAX_NB = 15
MAX_DECODE_LEN = 100
class JTNNDecoder(nn.Module):
def __init__(self, vocab, hidden_s... | 13,820 | 38.945087 | 440 | py |
FastJTNNpy3 | FastJTNNpy3-master/fast_jtnn/sascorer.py | #
# calculation of synthetic accessibility score as described in:
#
# Estimation of Synthetic Accessibility Score of Drug-like Molecules based on Molecular Complexity and Fragment Contributions
# Peter Ertl and Ansgar Schuffenhauer
# Journal of Cheminformatics 1:8 (2009)
# http://www.jcheminf.com/content/1/1/8
#
# seve... | 5,680 | 33.852761 | 125 | py |
FastJTNNpy3 | FastJTNNpy3-master/fast_jtnn/__init__.py | from .mol_tree import Vocab, MolTree
from .jtnn_vae import JTNNVAE
from .jtnn_enc import JTNNEncoder
from .jtmpn import JTMPN
from .mpn import MPN
from .nnutils import create_var
from .datautils import MolTreeFolder, PairTreeFolder, MolTreeDataset
| 248 | 30.125 | 68 | py |
FastJTNNpy3 | FastJTNNpy3-master/fast_jtnn/chemutils.py | import rdkit
import rdkit.Chem as Chem
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import minimum_spanning_tree
from collections import defaultdict
from rdkit.Chem.EnumerateStereoisomers import EnumerateStereoisomers, StereoEnumerationOptions
from .vocab import Vocab
MST_MAX_WEIGHT = 100
MAX_NCAND =... | 16,776 | 38.016279 | 440 | py |
FastJTNNpy3 | FastJTNNpy3-master/fast_molopt/pretrain.py | import torch
import torch.nn as nn
import torch.optim as optim
import torch.optim.lr_scheduler as lr_scheduler
from torch.utils.data import DataLoader
from torch.autograd import Variable
import math, random, sys
from optparse import OptionParser
from collections import deque
from jtnn import *
import rdkit
lg = rdki... | 3,110 | 32.095745 | 149 | py |
FastJTNNpy3 | FastJTNNpy3-master/fast_molopt/vaetrain.py | import torch
import torch.nn as nn
import torch.optim as optim
import torch.optim.lr_scheduler as lr_scheduler
from torch.utils.data import DataLoader
from torch.autograd import Variable
import math, random, sys
from optparse import OptionParser
from collections import deque
from jtnn import *
import rdkit
lg = rdki... | 3,695 | 33.542056 | 149 | py |
FastJTNNpy3 | FastJTNNpy3-master/fast_molopt/optimize.py | import torch
import torch.nn as nn
from torch.autograd import Variable
import math, random, sys
from optparse import OptionParser
from collections import deque
import rdkit
import rdkit.Chem as Chem
from rdkit.Chem import Descriptors
import sascorer
from jtnn import *
lg = rdkit.RDLogger.logger()
lg.setLevel(rdkit... | 1,845 | 29.766667 | 85 | py |
FastJTNNpy3 | FastJTNNpy3-master/fast_molopt/sascorer.py | #
# calculation of synthetic accessibility score as described in:
#
# Estimation of Synthetic Accessibility Score of Drug-like Molecules based on Molecular Complexity and Fragment Contributions
# Peter Ertl and Ansgar Schuffenhauer
# Journal of Cheminformatics 1:8 (2009)
# http://www.jcheminf.com/content/1/1/8
#
# seve... | 5,566 | 33.153374 | 125 | py |
FastJTNNpy3 | FastJTNNpy3-master/Old/molvae/pretrain.py | import torch
import torch.nn as nn
import torch.optim as optim
import torch.optim.lr_scheduler as lr_scheduler
from torch.utils.data import DataLoader
from torch.autograd import Variable
import math, random, sys
from optparse import OptionParser
from collections import deque
from jtnn import Vocab, JTNNVAE, MoleculeD... | 2,973 | 31.326087 | 128 | py |
FastJTNNpy3 | FastJTNNpy3-master/Old/molvae/sample.py | import torch
import torch.nn as nn
import torch.optim as optim
import torch.optim.lr_scheduler as lr_scheduler
from torch.autograd import Variable
import math, random, sys
from optparse import OptionParser
from collections import deque
import rdkit
import rdkit.Chem as Chem
from rdkit.Chem import Draw
from jtnn impor... | 1,368 | 28.76087 | 77 | py |
FastJTNNpy3 | FastJTNNpy3-master/Old/molvae/vaetrain.py | import torch
import torch.nn as nn
import torch.optim as optim
import torch.optim.lr_scheduler as lr_scheduler
from torch.utils.data import DataLoader
from torch.autograd import Variable
import math, random, sys
from optparse import OptionParser
from collections import deque
from jtnn import *
import rdkit
lg = rdki... | 3,544 | 32.443396 | 127 | py |
FastJTNNpy3 | FastJTNNpy3-master/Old/molvae/reconstruct.py | import torch
import torch.nn as nn
from torch.autograd import Variable
import math, random, sys
from optparse import OptionParser
from collections import deque
import rdkit
import rdkit.Chem as Chem
from jtnn import *
lg = rdkit.RDLogger.logger()
lg.setLevel(rdkit.RDLogger.CRITICAL)
parser = OptionParser()
parser... | 1,586 | 24.190476 | 68 | py |
FastJTNNpy3 | FastJTNNpy3-master/Old/molvae/draw_nei.py | import torch
import torch.nn as nn
from torch.autograd import Variable
import math, random, sys
from optparse import OptionParser
import rdkit
import rdkit.Chem as Chem
from rdkit.Chem import Draw
import numpy as np
from jtnn import *
lg = rdkit.RDLogger.logger()
lg.setLevel(rdkit.RDLogger.CRITICAL)
parser = Opti... | 1,797 | 27.539683 | 86 | py |
FastJTNNpy3 | FastJTNNpy3-master/Old/molvae/jtnn/jtnn_enc.py | import torch
import torch.nn as nn
from collections import deque
from mol_tree import Vocab, MolTree
from nnutils import create_var, GRU
MAX_NB = 8
class JTNNEncoder(nn.Module):
def __init__(self, vocab, hidden_size, embedding=None):
super(JTNNEncoder, self).__init__()
self.hidden_size = hidden_s... | 3,664 | 30.324786 | 84 | py |
FastJTNNpy3 | FastJTNNpy3-master/Old/molvae/jtnn/datautils.py | from torch.utils.data import Dataset
from mol_tree import MolTree
import numpy as np
class MoleculeDataset(Dataset):
def __init__(self, data_file):
with open(data_file) as f:
self.data = [line.strip("\r\n ").split()[0] for line in f]
def __len__(self):
return len(self.data)
... | 985 | 24.947368 | 70 | py |
FastJTNNpy3 | FastJTNNpy3-master/Old/molvae/jtnn/nnutils.py | import torch
import torch.nn as nn
from torch.autograd import Variable
def create_var(tensor, requires_grad=None):
if requires_grad is None:
return Variable(tensor)
else:
return Variable(tensor, requires_grad=requires_grad)
def index_select_ND(source, dim, index):
index_size = index.size()... | 968 | 25.916667 | 60 | py |
FastJTNNpy3 | FastJTNNpy3-master/Old/molvae/jtnn/mpn.py | import torch
import torch.nn as nn
import rdkit.Chem as Chem
import torch.nn.functional as F
from nnutils import *
from chemutils import get_mol
ELEM_LIST = ['C', 'N', 'O', 'S', 'F', 'Si', 'P', 'Cl', 'Br', 'Mg', 'Na', 'Ca', 'Fe', 'Al', 'I', 'B', 'K', 'Se', 'Zn', 'H', 'Cu', 'Mn', 'unknown']
ATOM_FDIM = len(ELEM_LIST) ... | 4,279 | 33.24 | 171 | py |
FastJTNNpy3 | FastJTNNpy3-master/Old/molvae/jtnn/jtnn_vae.py | import torch
import torch.nn as nn
from mol_tree import Vocab, MolTree
from nnutils import create_var
from jtnn_enc import JTNNEncoder
from jtnn_dec import JTNNDecoder
from mpn import MPN, mol2graph
from jtmpn import JTMPN
from chemutils import enum_assemble, set_atommap, copy_edit_mol, attach_mols, atom_equal, decode... | 13,071 | 40.897436 | 144 | py |
FastJTNNpy3 | FastJTNNpy3-master/Old/molvae/jtnn/mol_tree.py | import rdkit
import rdkit.Chem as Chem
import copy
from chemutils import get_clique_mol, tree_decomp, get_mol, get_smiles, set_atommap, enum_assemble, decode_stereo
import sys
import argparse
def get_slots(smiles):
mol = Chem.MolFromSmiles(smiles)
return [(atom.GetSymbol(), atom.GetFormalCharge(), atom.GetTot... | 5,224 | 31.65625 | 113 | py |
FastJTNNpy3 | FastJTNNpy3-master/Old/molvae/jtnn/jtprop_vae.py | import torch
import torch.nn as nn
from mol_tree import Vocab, MolTree
from nnutils import create_var
from jtnn_enc import JTNNEncoder
from jtnn_dec import JTNNDecoder
from mpn import MPN, mol2graph
from jtmpn import JTMPN
from chemutils import enum_assemble, set_atommap, copy_edit_mol, attach_mols, atom_equal, decode... | 14,765 | 40.711864 | 144 | py |
FastJTNNpy3 | FastJTNNpy3-master/Old/molvae/jtnn/jtmpn.py | import torch
import torch.nn as nn
from nnutils import create_var, index_select_ND
from chemutils import get_mol
#from mpn import atom_features, bond_features, ATOM_FDIM, BOND_FDIM
import rdkit.Chem as Chem
ELEM_LIST = ['C', 'N', 'O', 'S', 'F', 'Si', 'P', 'Cl', 'Br', 'Mg', 'Na', 'Ca', 'Fe', 'Al', 'I', 'B', 'K', 'Se', ... | 5,326 | 37.323741 | 184 | py |
FastJTNNpy3 | FastJTNNpy3-master/Old/molvae/jtnn/jtnn_dec.py | import torch
import torch.nn as nn
from mol_tree import Vocab, MolTree, MolTreeNode
from nnutils import create_var, GRU
from chemutils import enum_assemble
import copy
MAX_NB = 8
MAX_DECODE_LEN = 100
class JTNNDecoder(nn.Module):
def __init__(self, vocab, hidden_size, latent_size, embedding=None):
super(... | 12,422 | 37.580745 | 118 | py |
FastJTNNpy3 | FastJTNNpy3-master/Old/molvae/jtnn/__init__.py | from mol_tree import Vocab, MolTree
from jtnn_vae import JTNNVAE
from jtprop_vae import JTPropVAE
from mpn import MPN, mol2graph
from nnutils import create_var
from datautils import MoleculeDataset, PropDataset
from chemutils import decode_stereo
| 247 | 30 | 50 | py |
FastJTNNpy3 | FastJTNNpy3-master/Old/molvae/jtnn/chemutils.py | import rdkit
import rdkit.Chem as Chem
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import minimum_spanning_tree
from collections import defaultdict
from rdkit.Chem.EnumerateStereoisomers import EnumerateStereoisomers, StereoEnumerationOptions
MST_MAX_WEIGHT = 100
MAX_NCAND = 2000
def set_atommap(mo... | 15,275 | 37.478589 | 440 | py |
FastJTNNpy3 | FastJTNNpy3-master/Old/molopt/pretrain.py | import torch
import torch.nn as nn
import torch.optim as optim
import torch.optim.lr_scheduler as lr_scheduler
from torch.utils.data import DataLoader
from torch.autograd import Variable
import math, random, sys
from optparse import OptionParser
from collections import deque
from jtnn import *
import rdkit
lg = rdki... | 3,110 | 32.095745 | 149 | py |
FastJTNNpy3 | FastJTNNpy3-master/Old/molopt/vaetrain.py | import torch
import torch.nn as nn
import torch.optim as optim
import torch.optim.lr_scheduler as lr_scheduler
from torch.utils.data import DataLoader
from torch.autograd import Variable
import math, random, sys
from optparse import OptionParser
from collections import deque
from jtnn import *
import rdkit
lg = rdki... | 3,695 | 33.542056 | 149 | py |
FastJTNNpy3 | FastJTNNpy3-master/Old/molopt/optimize.py | import torch
import torch.nn as nn
from torch.autograd import Variable
import math, random, sys
from optparse import OptionParser
from collections import deque
import rdkit
import rdkit.Chem as Chem
from rdkit.Chem import Descriptors
import sascorer
from jtnn import *
lg = rdkit.RDLogger.logger()
lg.setLevel(rdkit... | 1,845 | 29.766667 | 85 | py |
FastJTNNpy3 | FastJTNNpy3-master/Old/molopt/sascorer.py | #
# calculation of synthetic accessibility score as described in:
#
# Estimation of Synthetic Accessibility Score of Drug-like Molecules based on Molecular Complexity and Fragment Contributions
# Peter Ertl and Ansgar Schuffenhauer
# Journal of Cheminformatics 1:8 (2009)
# http://www.jcheminf.com/content/1/1/8
#
# seve... | 5,566 | 33.153374 | 125 | py |
FastJTNNpy3 | FastJTNNpy3-master/Old/dataV1/select.py | import rdkit
from rdkit.Chem import Descriptors
from rdkit.Chem import MolFromSmiles, MolToSmiles
from rdkit.Chem import rdmolops
import sascorer
import numpy as np
import sys
lg = rdkit.RDLogger.logger()
lg.setLevel(rdkit.RDLogger.CRITICAL)
smiles = []
for line in sys.stdin:
smiles.append(line.strip())
targe... | 615 | 22.692308 | 60 | py |
FastJTNNpy3 | FastJTNNpy3-master/Old/bo/gauss.py |
import theano
import theano.tensor as T
import numpy as np
from scipy.spatial.distance import cdist
def casting(x):
return np.array(x).astype(theano.config.floatX)
def compute_kernel(lls, lsf, x, z):
ls = T.exp(lls)
sf = T.exp(lsf)
if x.ndim == 1:
x = x[ None, : ]
if z.ndim == 1:
... | 4,638 | 31.440559 | 123 | py |
FastJTNNpy3 | FastJTNNpy3-master/Old/bo/print_result.py | import sys
import gzip
import pickle
import rdkit.Chem as Chem
from rdkit.Chem import Draw
from rdkit.Chem import Descriptors
import sascorer
def save_object(obj, filename):
result = pickle.dumps(obj)
with gzip.GzipFile(filename, 'wb') as dest: dest.write(result)
dest.close()
def load_object(filename):
... | 1,093 | 28.567568 | 96 | py |
FastJTNNpy3 | FastJTNNpy3-master/Old/bo/gen_latent.py | import torch
import torch.nn as nn
from torch.autograd import Variable
from optparse import OptionParser
import rdkit
from rdkit.Chem import Descriptors
from rdkit.Chem import MolFromSmiles, MolToSmiles
from rdkit.Chem import rdmolops
import sascorer
import numpy as np
from jtnn import *
lg = rdkit.RDLogger.logger... | 2,922 | 31.120879 | 104 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.