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
spyn-repr
spyn-repr-master/dataset.py
import numpy import csv import re DATA_PATH = "data/" DATA_FULL_PATH = DATA_PATH + 'full/' DATASET_NAMES = ['accidents', 'ad', 'baudio', 'bbc', 'bnetflix', 'book', 'c20ng', 'cr52', ...
11,393
28.594805
88
py
spyn-repr
spyn-repr-master/caltech101.py
import numpy import matplotlib import matplotlib.pyplot as pyplot import pickle import os from scipy.io import loadmat RANDOM_SEED = 1337 def load_caltech101_from_mat(data_path, split_names=['train', 'val', ...
2,154
28.121622
84
py
spyn-repr
spyn-repr-master/visualize.py
from spn import MARG_IND import numpy import matplotlib # matplotlib.use('Agg') import matplotlib.pyplot as pyplot from matplotlib.backends.backend_pdf import PdfPages import matplotlib.gridspec as gridspec from matplotlib.colors import LogNorm # from spn.utils import get_best_value_from_frame import seaborn from...
33,780
29.765938
95
py
spyn-repr
spyn-repr-master/mnist.py
from visualize import array_2_mat from visualize import plot_m_by_n_images import numpy import matplotlib import matplotlib.pyplot as pyplot import pickle import os RANDOM_SEED = 1337 def load_mnist_data_split_from_txt(data_path): data = numpy.loadtxt(data_path, delimiter=' ') x, y = data[:, :-1], dat...
2,696
27.691489
99
py
spyn-repr
spyn-repr-master/bin/eval_spn.py
import argparse try: from time import perf_counter except: from time import time perf_counter = time import dataset import numpy import datetime import os import logging from spn.utils import stats_format from spn.linked.spn import evaluate_on_dataset from spn.theanok.spn import evaluate_on_dataset_...
5,069
31.292994
83
py
spyn-repr
spyn-repr-master/bin/mtlearn_exp.py
import subprocess import numpy import os import argparse import logging import datetime import re try: from time import perf_counter except: from time import time as perf_counter MTLEARN_EXEC = './mtlearn' MSCORE_EXEC = './mscore' SPN2AC_EXEC = './spn2ac' SPN_EXT = '.spn' AC_EXT = '.ac' DATA_DIR = 'd...
13,099
31.26601
93
py
spyn-repr
spyn-repr-master/bin/classify_repr_exp.py
import argparse try: from time import perf_counter except: from time import time perf_counter = time import dataset import numpy import datetime import os import logging from spn.utils import stats_format from sklearn.preprocessing import StandardScaler from sklearn import linear_model from sklear...
17,148
35.721627
108
py
spyn-repr
spyn-repr-master/bin/filter_feature_repr.py
import argparse try: from time import perf_counter except: from time import time perf_counter = time import dataset import numpy import datetime import os import logging from spn.utils import stats_format from spn import MARG_IND from spn.linked.nodes import SumNode from spn.linked.nodes import Prod...
12,095
35
96
py
spyn-repr
spyn-repr-master/bin/rbm_repr_data.py
import argparse try: from time import perf_counter except: from time import time perf_counter = time import dataset import numpy import datetime import os import logging from sklearn import neural_network from spn.utils import stats_format from spn import MARG_IND import pickle MODEL_EXT = 'model'...
16,883
39.684337
96
py
spyn-repr
spyn-repr-master/bin/theanok_benchmark.py
import sys sys.setrecursionlimit(50000) import dataset import numpy from numpy.testing import assert_array_almost_equal import theano.misc.pkl_utils import datetime import os import logging from spn.utils import stats_format from spn.linked.spn import evaluate_on_dataset from spn.theanok.spn import * from spn.t...
5,970
31.451087
92
py
spyn-repr
spyn-repr-master/bin/marg_feature_gen.py
import argparse try: from time import perf_counter except: from time import time perf_counter = time import dataset import numpy import datetime import os import logging from spn import MARG_IND from spn.linked.representation import extract_features_marginalization_rand from spn.linked.representatio...
6,508
38.448485
104
py
spyn-repr
spyn-repr-master/bin/visualize_spn.py
from spn import MARG_IND from spn.utils import stats_format from spn.utils import approx_scope_histo_quartiles from spn.linked.spn import evaluate_on_dataset from spn.linked.nodes import SumNode from spn.linked.nodes import ProductNode from spn.linked.representation import load_features_from_file from spn.linked.rep...
59,334
41.748559
114
py
spyn-repr
spyn-repr-master/bin/spn_repr_data.py
import sys sys.setrecursionlimit(1000000000) import argparse try: from time import perf_counter except: from time import time perf_counter = time import dataset import numpy import datetime import os import logging from spn.utils import stats_format from spn import MARG_IND from spn.linked.represen...
35,122
41.990208
105
py
spyn-repr
spyn-repr-master/bin/merge_repr.py
from spn.linked.representation import load_features_from_file from spn.linked.representation import save_features_to_file import numpy from numpy.testing import assert_array_equal import os import logging import argparse import pickle DATA_EXT = 'data' TRAIN_DATA_EXT = 'ts.{}'.format(DATA_EXT) VALID_DATA_EXT = 'v...
5,310
32.19375
95
py
spyn-repr
spyn-repr-master/bin/feature_split.py
from spn.linked.representation import load_features_from_file from spn.linked.representation import save_features_to_file import numpy from numpy.testing import assert_array_equal import os import logging import argparse def batch_feature_split(feature_path, batch_size): # # load features first featur...
2,748
32.938272
102
py
spyn-repr
spyn-repr-master/bin/libra_repr_data.py
import argparse try: from time import perf_counter except: from time import time perf_counter = time import dataset import numpy import datetime import os import logging from spn.utils import stats_format from spn import MARG_IND from spn.linked.representation import extract_features_marginalization...
9,969
36.481203
104
py
spyn-repr
spyn-repr-master/bin/learnspn_exp.py
import argparse try: from time import perf_counter except: from time import time perf_counter = time import dataset import numpy from numpy.testing import assert_almost_equal import random import datetime import os import logging from algo.learnspn import LearnSPN from spn import NEG_INF from spn.u...
12,700
36.688427
89
py
spyn-repr
spyn-repr-master/tests/test_dataset.py
import dataset import numpy def test_sampling(): # loading nltcs print('Loading datasets') train, valid, test = dataset.load_train_val_test_csvs('nltcs') # checking for their shape n_instances = train.shape[0] n_test_instances = test.shape[0] n_valid_instances = valid.shape[0] nltcs...
3,136
31.010204
75
py
spyn-repr
spyn-repr-master/cltree/probs.py
import numpy import numba @numba.jit def scope_union(factor_scope_1, factor_scope_2): """ A factor scope is a numpy boolean array """ return factor_scope_1 + factor_scope_2 #@numba.njit def factor_length(factor_scope, feature_vals): """ WRITEME """ f_scope = feature_vals[factor_scope...
4,185
26.539474
71
py
spyn-repr
spyn-repr-master/cltree/utils.py
import graphviz from cltree.cltree import CLTree def add_nodes(graph, nodes): """ """ for n in nodes: if isinstance(n, tuple): graph.node(n[0], **n[1]) else: graph.node(n) return graph def add_edges(graph, edges): for e in edges: if isinstance(e[0...
2,592
21.745614
65
py
spyn-repr
spyn-repr-master/cltree/cltree.py
import numpy import numba import scipy.sparse from scipy.sparse.csgraph import minimum_spanning_tree from scipy.sparse.csgraph import depth_first_order from spn import LOG_ZERO @numba.njit def safe_log(x): """ Assuming x to be a scalar """ if x > 0.0: return numpy.log(x) else: r...
25,021
31.923684
86
py
spyn-repr
spyn-repr-master/cltree/__init__.py
0
0
0
py
spyn-repr
spyn-repr-master/cltree/tests/test_probs.py
import numpy from cltree.probs import numba_cumsum from cltree.probs import scope_union from cltree.probs import compute_factor_stride from cltree.probs import n_factor_features from cltree.probs import compute_factor_product from cltree.probs import factor_product from cltree.probs import factor_length from numpy.te...
5,481
35.791946
76
py
spyn-repr
spyn-repr-master/cltree/tests/test_cltree.py
from spn import LOG_ZERO import numpy from numpy.testing import assert_almost_equal from numpy.testing import assert_array_almost_equal from numpy.testing import assert_array_equal # from cltree.cltree import minimum_spanning_tree # from cltree.cltree import minimum_spanning_tree_numba from cltree.cltree import CLT...
20,553
31.470774
86
py
spyn-repr
spyn-repr-master/algo/learnspn.py
import numpy import numba from scipy.misc import logsumexp import sys import itertools try: from time import perf_counter except: from time import time perf_counter = time from spn import MARG_IND from spn import LOG_ZERO from spn import RND_SEED from spn.linked.nodes import CategoricalSmoothedNode f...
61,098
37.044209
98
py
spyn-repr
spyn-repr-master/algo/__init__.py
0
0
0
py
spyn-repr
spyn-repr-master/algo/dataslice.py
import numpy try: from time import perf_counter except: from time import time perf_counter = time from spn import LOG_ZERO class DataSlice(object): """ A little util class for storing the sets of indexes for the instances and features considered """ class_counter = 0 @clas...
4,572
24.547486
96
py
spyn-repr
spyn-repr-master/spn/utils.py
try: from itertools import izip as zip except: pass import itertools from itertools import tee import numpy import scipy import scipy.stats import os import visualize import pandas import glob def pairwise(iterable): """ s = <s0, s1, ...> s -> (s0,s1), (s1,s2), (s2, s3), ... """ a,...
13,105
31.201474
87
py
spyn-repr
spyn-repr-master/spn/factory.py
from spn.linked.spn import Spn as SpnLinked from spn.linked.layers import Layer as LayerLinked from spn.linked.layers import SumLayer as SumLayerLinked from spn.linked.layers import ProductLayer as ProductLayerLinked from spn.linked.layers import CategoricalInputLayer from spn.linked.layers import CategoricalSmoothedL...
56,522
36.358229
97
py
spyn-repr
spyn-repr-master/spn/__init__.py
import sys # marginalize indicator MARG_IND = -1 # log of zero const, to avoid -inf # numpy.exp(LOG_ZERO) = 0 LOG_ZERO = -1e3 def IS_LOG_ZERO(log_val): """ checks for a value to represent the logarithm of 0. The identity to be verified is that: IS_LOG_ZERO(x) && exp(x) == 0 according to the cons...
6,449
21.089041
76
py
spyn-repr
spyn-repr-master/spn/theanok/initializations.py
import numpy as np import theano import theano.tensor as T def floatX(X): return np.asarray(X, dtype=theano.config.floatX) def sharedX(X, dtype=theano.config.floatX, name=None): return theano.shared(np.asarray(X, dtype=dtype), name=name) def shared_zeros(shape, dtype=theano.config.floatX, name=None): ...
1,260
22.351852
73
py
spyn-repr
spyn-repr-master/spn/theanok/layers.py
import numpy import theano import theano.tensor as T from spn import LOG_ZERO from .initializations import Initialization, sharedX, ndim_tensor import os # # inspired by Keras # def exp_activation(x): return T.exp(x) def log_activation(x): return T.log(x).clip(LOG_ZERO, 0.) def log_sum_exp_activation(x...
13,956
28.259958
105
py
spyn-repr
spyn-repr-master/spn/theanok/__init__.py
0
0
0
py
spyn-repr
spyn-repr-master/spn/theanok/spn.py
import numpy import theano import theano.tensor as T from .initializations import ndim_tensor import sys # from .layers import TheanokLayer # from .layers import SumLayer_logspace # from .layers import ProductLayer_logspace # from .layers import InputLayer_logspace import theano.misc.pkl_utils import pickle from c...
7,735
24.363934
86
py
spyn-repr
spyn-repr-master/spn/theanok/tests/test_layers.py
import numpy from numpy.testing import assert_array_almost_equal import theano from spn.theanok.layers import SumLayer, ProductLayer from ..layers import SumLayer_logspace from ..layers import ProductLayer_logspace from ..layers import MaxLayer_logspace from spn import LOG_ZERO def test_theano_sum_layer(): inp...
8,281
29.116364
83
py
spyn-repr
spyn-repr-master/spn/theanok/tests/test_spn.py
import numpy from numpy.testing import assert_array_almost_equal import theano from ..spn import SequentialSpn from ..spn import BlockLayeredSpn from ..layers import SumLayer, ProductLayer from ..layers import SumLayer_logspace from ..layers import ProductLayer_logspace from ..layers import MaxLayer_logspace from sp...
11,884
29.24173
76
py
spyn-repr
spyn-repr-master/spn/theanok/tests/__init__.py
0
0
0
py
spyn-repr
spyn-repr-master/spn/linked/nodes.py
from spn import utils from spn import LOG_ZERO from spn import MARG_IND from spn import IS_LOG_ZERO from spn import RND_SEED import numpy from math import log from math import exp from cltree.cltree import CLTree import dataset import numba from collections import defaultdict NODE_SYM = 'u' # unknown type SUM_...
28,838
28.159757
97
py
spyn-repr
spyn-repr-master/spn/linked/weight_learning.py
import numpy from scipy.misc import logsumexp import numba from .nodes import SumNode from .nodes import ProductNode from .nodes import CategoricalSmoothedNode from .nodes import CategoricalIndicatorNode from .nodes import CLTreeNode from ..factory import retrieve_children_parent_assoc from collections import dequ...
9,524
27.951368
83
py
spyn-repr
spyn-repr-master/spn/linked/learning.py
from spn.linked.spn import Spn from spn.linked.nodes import SumNode from spn.linked.nodes import ProductNode from spn.linked.nodes import CategoricalSmoothedNode from spn.linked.layers import SumLayer from spn.linked.layers import ProductLayer from spn.linked.layers import CategoricalSmoothedLayer from spn.factory i...
51,985
34.316576
79
py
spyn-repr
spyn-repr-master/spn/linked/layers.py
from spn.linked.nodes import SumNode from spn.linked.nodes import ProductNode from spn.linked.nodes import CategoricalIndicatorNode from spn.linked.nodes import CategoricalSmoothedNode from spn.linked.nodes import CLTreeNode from math import exp import numba @numba.jit def eval_numba(nodes): for node in nodes: ...
13,261
24.357553
99
py
spyn-repr
spyn-repr-master/spn/linked/__init__.py
0
0
0
py
spyn-repr
spyn-repr-master/spn/linked/representation.py
from .nodes import SumNode from .nodes import ProductNode from .nodes import mpe_states_from_leaf from spn import RND_SEED from spn import MARG_IND from spn.linked.spn import evaluate_on_dataset from spn.theanok.spn import evaluate_on_dataset_batch from dataset import dataset_to_instances_set from collections import...
65,192
34.087729
98
py
spyn-repr
spyn-repr-master/spn/linked/spn.py
from .layers import Layer from .layers import SumLayer from .layers import ProductLayer from .layers import compute_feature_vals from spn import AbstractSpn, AbstractLayeredSpn from spn import LOG_ZERO from spn import RND_SEED from .nodes import SumNode from .nodes import ProductNode from .nodes import sample_from_l...
32,300
33.546524
97
py
spyn-repr
spyn-repr-master/spn/linked/tests/test_layers.py
from spn.linked.layers import Layer from spn.linked.layers import ProductLayer from spn.linked.layers import SumLayer from spn.linked.layers import CategoricalInputLayer from spn.linked.layers import CategoricalIndicatorLayer from spn.linked.layers import CategoricalSmoothedLayer from spn.linked.layers import Categoric...
27,427
27.422798
78
py
spyn-repr
spyn-repr-master/spn/linked/tests/test_weight_learning.py
import numpy from numpy.testing import assert_array_almost_equal from ..weight_learning import evaluate_indicator_node from ..weight_learning import evaluate_categorical_node from ..weight_learning import evaluate_sum_node from ..weight_learning import evaluate_product_node from ..weight_learning import ml_evaluation ...
9,356
34.988462
98
py
spyn-repr
spyn-repr-master/spn/linked/tests/test_representation.py
import dataset from spn import MARG_IND from ..spn import Spn from ..spn import evaluate_on_dataset from ..layers import SumLayer from ..layers import ProductLayer from ..layers import CategoricalIndicatorLayer from ..nodes import SumNode from ..nodes import ProductNode from ..nodes import CategoricalIndicatorNode ...
32,624
34.655738
101
py
spyn-repr
spyn-repr-master/spn/linked/tests/test_spn.py
from spn.linked.spn import Spn from spn.linked.layers import SumLayer from spn.linked.layers import ProductLayer from spn.linked.layers import CategoricalIndicatorLayer from spn.linked.layers import CategoricalSmoothedLayer from spn.linked.layers import CategoricalInputLayer from ..nodes import SumNode from ..nodes i...
30,480
28.679649
95
py
spyn-repr
spyn-repr-master/spn/linked/tests/__init__.py
0
0
0
py
spyn-repr
spyn-repr-master/spn/linked/tests/test_nodes.py
from spn.linked.nodes import Node from spn.linked.nodes import SumNode from spn.linked.nodes import ProductNode from spn.linked.nodes import CategoricalIndicatorNode from spn.linked.nodes import CategoricalSmoothedNode from spn.linked.nodes import CLTreeNode from spn.tests import compute_smoothed_ll from spn import L...
21,756
27.515072
79
py
spyn-repr
spyn-repr-master/spn/linked/tests/test_learning.py
from spn.linked.spn import Spn from spn.linked.layers import CategoricalIndicatorLayer from spn.linked.layers import SumLayer from spn.linked.layers import ProductLayer from spn.linked.nodes import SumNode from spn.linked.nodes import ProductNode import numpy from numpy.testing import assert_almost_equal from numpy....
15,315
30.841996
88
py
normalizing_flows
normalizing_flows-master/test.py
import torch import torch.nn as nn import torch.nn.functional as F import torch.distributions as D from torch.utils.data import DataLoader, Dataset import unittest from unittest.mock import MagicMock from maf import MADE, MADEMOG, MAF, MAFMOG, RealNVP, BatchNorm, LinearMaskedCoupling, train from glow import Actnorm, ...
17,209
45.016043
156
py
normalizing_flows
normalizing_flows-master/data.py
from functools import partial import numpy as np import torch import torchvision.transforms as T from torch.utils.data import DataLoader, TensorDataset import datasets # -------------------- # Helper functions # -------------------- def logit(x, eps=1e-5): x.clamp_(eps, 1 - eps) return x.log() - (1 - x).log...
4,218
36.336283
146
py
normalizing_flows
normalizing_flows-master/glow.py
""" Glow: Generative Flow with Invertible 1x1 Convolutions arXiv:1807.03039v2 """ import torch import torch.nn as nn import torch.nn.functional as F import torch.distributions as D import torchvision.transforms as T from torchvision.utils import save_image, make_grid from torch.utils.data import DataLoader from torch....
35,698
45.302205
181
py
normalizing_flows
normalizing_flows-master/bnaf.py
""" Implementation of Block Neural Autoregressive Flow http://arxiv.org/abs/1904.04676 """ import torch import torch.nn as nn import torch.nn.functional as F import torch.distributions as D from torch.utils.data import DataLoader, TensorDataset import math import os import time import argparse import pprint from func...
20,690
42.836864
163
py
normalizing_flows
normalizing_flows-master/maf.py
""" Masked Autoregressive Flow for Density Estimation arXiv:1705.07057v4 """ import torch import torch.nn as nn import torch.nn.functional as F import torch.distributions as D import torchvision.transforms as T from torchvision.utils import save_image import matplotlib matplotlib.use('Agg') import matplotlib.pyplot a...
31,985
41.762032
169
py
normalizing_flows
normalizing_flows-master/planar_flow.py
""" Variational Inference with Normalizing Flows arXiv:1505.05770v6 """ import torch import torch.nn as nn import torch.distributions as D import math import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import os import argparse parser = argparse.ArgumentParser() # action parser.add_argument('-...
12,324
39.811258
151
py
normalizing_flows
normalizing_flows-master/datasets/power.py
import numpy as np import matplotlib.pyplot as plt import datasets import datasets.util class POWER: class Data: def __init__(self, data): self.x = data.astype(np.float32) self.N = self.x.shape[0] def __init__(self): trn, val, tst = load_data_normalised() ...
2,216
24.77907
108
py
normalizing_flows
normalizing_flows-master/datasets/moons.py
import torch import torch.distributions as D from torch.utils.data import Dataset from sklearn.datasets import make_moons class MOONS(Dataset): def __init__(self, dataset_size=25000, **kwargs): self.x, self.y = make_moons(n_samples=dataset_size, shuffle=True, noise=0.05) self.input_size = 2 ...
512
20.375
85
py
normalizing_flows
normalizing_flows-master/datasets/hepmass.py
import pandas as pd import numpy as np import matplotlib.pyplot as plt from collections import Counter from os.path import join import datasets import datasets.util class HEPMASS: """ The HEPMASS data set. http://archive.ics.uci.edu/ml/datasets/HEPMASS """ class Data: def __init__(self,...
3,029
28.134615
112
py
normalizing_flows
normalizing_flows-master/datasets/toy.py
import torch import torch.distributions as D from torch.utils.data import Dataset class ToyDistribution(D.Distribution): def __init__(self, flip_var_order): super().__init__() self.flip_var_order = flip_var_order self.p_x2 = D.Normal(0, 4) self.p_x1 = lambda x2: D.Normal(0.25 * x2*...
1,214
27.255814
90
py
normalizing_flows
normalizing_flows-master/datasets/gas.py
import pandas as pd import numpy as np import matplotlib.pyplot as plt import datasets import datasets.util class GAS: class Data: def __init__(self, data): self.x = data.astype(np.float32) self.N = self.x.shape[0] def __init__(self): file = datasets.root + 'gas/e...
1,954
22.27381
59
py
normalizing_flows
normalizing_flows-master/datasets/bsds300.py
import numpy as np import h5py import matplotlib.pyplot as plt import datasets import datasets.util class BSDS300: """ A dataset of patches from BSDS300. """ class Data: """ Constructs the dataset. """ def __init__(self, data): self.x = data[:] ...
1,905
23.435897
77
py
normalizing_flows
normalizing_flows-master/datasets/download_celeba.py
""" Source -- https://github.com/nperraud/download-celebA-HQ/ """ import requests import tarfile import zipfile import gzip import os import hashlib import sys from glob import glob from urllib.request import urlretrieve from subprocess import Popen import argparse from tqdm import tqdm parser = argparse.ArgumentPars...
8,603
32.478599
83
py
normalizing_flows
normalizing_flows-master/datasets/util.py
""" Select dataset functions from MAF repo https://github.com/gpapamak/maf/blob/master/util.py """ import numpy as np import matplotlib.pyplot as plt def plot_hist_marginals(data, lims=None, gt=None): """ Plots marginal histograms and pairwise scatter plots of a dataset. """ n_bins = int(np.sqrt(data...
2,135
27.864865
117
py
normalizing_flows
normalizing_flows-master/datasets/miniboone.py
import numpy as np import matplotlib.pyplot as plt import datasets import datasets.util class MINIBOONE: class Data: def __init__(self, data): self.x = data.astype(np.float32) self.N = self.x.shape[0] def __init__(self): file = datasets.root + 'miniboone/data.npy'...
2,250
26.790123
96
py
normalizing_flows
normalizing_flows-master/datasets/__init__.py
root = 'data/' #from .power import POWER #from .gas import GAS #from .hepmass import HEPMASS #from .miniboone import MINIBOONE #from .bsds300 import BSDS300 #from .toy import TOY #from .moons import MOONS #from .mnist import MNIST #from torchvision.datasets import MNIST, CIFAR10
283
19.285714
48
py
normalizing_flows
normalizing_flows-master/datasets/celeba.py
import os from PIL import Image import numpy as np import torch from torch.utils.data import Dataset class CelebA(Dataset): processed_file = 'processed.pt' partition_file = 'Eval/list_eval_partition.txt' attr_file = 'Anno/list_attr_celeba.txt' img_folder = 'Img/img_align_celeba' attr_names = '5_o_...
5,419
43.793388
490
py
normalizing_flows
normalizing_flows-master/datasets/mnist.py
import numpy as np import gzip import pickle import matplotlib.pyplot as plt import datasets import datasets.util as util class MNIST: """ The MNIST dataset of handwritten digits. """ alpha = 1.0e-6 class Data: """ Constructs the dataset. """ def __init__(self, ...
2,886
28.459184
97
py
SpinalNet
SpinalNet-master/Regression/Regression_NN_and_SpinalNet.py
# -*- coding: utf-8 -*- """ This script performs regression on toy datasets. There exist several relations between inputs and output. We investigate both of the traditional feed-forward and SpinalNet for all of these input-output relations. ---------- Multiplication: y = x1*x2*x3*x4*x5*x6*x7*x8 + 0.2*torch.rand(x1...
5,420
28.302703
105
py
SpinalNet
SpinalNet-master/Transfer Learning/Transfer_Learning_hymenoptera.py
''' Most part of the code and dataset is copied from PyTorch demo: https://pytorch.org/tutorials/beginner/transfer_learning_tutorial.html ''' from __future__ import print_function, division import torch import torch.nn as nn import torch.optim as optim from torch.optim import lr_scheduler import numpy as np impor...
7,504
29.384615
78
py
SpinalNet
SpinalNet-master/Transfer Learning/Transfer_Learning_STL10.py
''' We write this code with the help of PyTorch demo: https://pytorch.org/tutorials/beginner/transfer_learning_tutorial.html Data is downloaded from pytorch and divided into folders using script 'Pytorch_data_to_folders.py' Effects: transforms.Resize((272,272)), transforms.RandomRotation(15,), ...
7,704
30.068548
93
py
SpinalNet
SpinalNet-master/Transfer Learning/Transfer_Learning_CIFAR100.py
''' We write this code with the help of PyTorch demo: https://pytorch.org/tutorials/beginner/transfer_learning_tutorial.html Dataset is distributed in folders with following script: https://au.mathworks.com/matlabcentral/answers/329597-save-cifar-100-images Performances: Data augmentation: transforms.Res...
8,199
28.818182
93
py
SpinalNet
SpinalNet-master/Transfer Learning/Transfer_Learning_CIFAR10.py
''' We write this code with the help of PyTorch demo: https://pytorch.org/tutorials/beginner/transfer_learning_tutorial.html The dataset is downloaded from https://www.kaggle.com/swaroopkml/cifar10-pngs-in-folders Performances: Data augmentation: transforms.Resize((272,272)), transforms.RandomRotati...
9,644
30.314935
93
py
SpinalNet
SpinalNet-master/Transfer Learning/Transfer_Learning_SVHN.py
''' Data is downloaded from pytorch and divided into folders using script 'Pytorch_data_to_folders.py' Effects: transforms.Resize((272,320)), transforms.RandomRotation(15,), transforms.CenterCrop(272), transforms.RandomCrop(256), transforms.ToTensor(), wide_resnet101_2 Spinal...
9,514
30.611296
93
py
SpinalNet
SpinalNet-master/Transfer Learning/Transfer_Learning_CINIC10.py
''' We write this code with the help of PyTorch demo: https://pytorch.org/tutorials/beginner/transfer_learning_tutorial.html The Dataset is downloaded from https://www.kaggle.com/mengcius/cinic10 Effects: transforms.Resize((272,272)), transforms.RandomRotation(15,), transforms.RandomC...
10,712
31.761468
113
py
SpinalNet
SpinalNet-master/Transfer Learning/Transfer_Learning_Caltech101.py
''' We write this code with the help of PyTorch demo: https://pytorch.org/tutorials/beginner/transfer_learning_tutorial.html Dataset is Downloaded from https://www.kaggle.com/huangruichu/caltech101/version/2 Effects: transforms.Resize((230,230)), transforms.RandomRotation(15,), transfo...
10,203
30.788162
93
py
SpinalNet
SpinalNet-master/Transfer Learning/Pytorch_data_to_folders.py
# -*- coding: utf-8 -*- """ We need to create train and val folders manually before running the script @author: Dipu """ import torchvision import matplotlib import matplotlib.pyplot as plt import numpy import imageio import os data_train = torchvision.datasets.SVHN('./data', split='train', download=True, ...
1,195
28.170732
83
py
SpinalNet
SpinalNet-master/Transfer Learning/Transfer_Learning_Fruits360.py
''' We write this code with the help of PyTorch demo: https://pytorch.org/tutorials/beginner/transfer_learning_tutorial.html Dataset is Downloaded from https://www.kaggle.com/moltean/fruits Effects: transforms.Resize((140,140)), transforms.RandomRotation(15,), transforms.RandomResizedC...
9,786
32.064189
93
py
SpinalNet
SpinalNet-master/Transfer Learning/Transfer_Learning_Stanford_Cars.py
''' Stanford Cars We write this code with the help of PyTorch demo: https://pytorch.org/tutorials/beginner/transfer_learning_tutorial.html Dataset is downloaded from https://www.kaggle.com/jutrera/stanford-car-dataset-by-classes-folder? Effect: transforms.Resize((456,456)), transforms.RandomRotat...
9,929
30.52381
97
py
SpinalNet
SpinalNet-master/Transfer Learning/Transfer_Learning_Oxford102flower.py
''' We write this code with the help of PyTorch demo: https://pytorch.org/tutorials/beginner/transfer_learning_tutorial.html The dataset is downloaded from https://www.kaggle.com/c/oxford-102-flower-pytorch/data Effects: transforms.Resize((464,464)), transforms.RandomRotation(15,), tra...
9,691
30.986799
93
py
SpinalNet
SpinalNet-master/Transfer Learning/Transfer_Learning_Bird225.py
''' We write this code with the help of PyTorch demo: https://pytorch.org/tutorials/beginner/transfer_learning_tutorial.html Data Link: https://www.kaggle.com/gpiosenka/100-bird-species Version 30 Downloaded on 20/08/2020 Performances: Data augmentation: transforms.Resize((230,230)), t...
8,387
28.850534
120
py
SpinalNet
SpinalNet-master/Transfer Learning/Transfer_Learning_MNIST.py
# Execution info: https://www.kaggle.com/dipuk0506/transfer-learning-on-mnist from __future__ import print_function, division import matplotlib import imageio import torch import torch.nn as nn import torch.optim as optim from torch.optim import lr_scheduler import numpy as np import torchvision from torchvision impo...
10,753
29.725714
93
py
SpinalNet
SpinalNet-master/CIFAR-10/ResNet_default_and_SpinalFC_CIFAR10.py
# -*- coding: utf-8 -*- """ This Script contains the default and Spinal ResNet code for CIFAR-10. This code trains both NNs as two different models. There is option of choosing ResNet18(), ResNet34(), SpinalResNet18(), or SpinalResNet34(). This code randomly changes the learning rate to get a good result. @author: ...
13,289
29.906977
101
py
SpinalNet
SpinalNet-master/CIFAR-10/VGG_default_and_SpinalFC_CIFAR10.py
# -*- coding: utf-8 -*- """ This Script contains the default and Spinal VGG code for CIFAR-10. This code trains both NNs as two different models. There is option of choosing NN among: vgg11_bn(), vgg13_bn(), vgg16_bn(), vgg19_bn() and Spinalvgg11_bn(), Spinalvgg13_bn(), Spinalvgg16_bn(), Spinalvgg19_bn() Thi...
8,991
28.578947
116
py
SpinalNet
SpinalNet-master/CIFAR-10/CNN_dropout_CIFAR10.py
# -*- coding: utf-8 -*- """ This Script contains the default CNN dropout code for comparison. The code is collected and changed from: https://zhenye-na.github.io/2018/09/28/pytorch-cnn-cifar10.html @author: Dipu """ import torch import torch.nn as nn import torchvision import torchvision.transforms as transfo...
4,878
27.04023
97
py
SpinalNet
SpinalNet-master/CIFAR-10/CNN_dropout_SpinalFC_CIFAR10.py
# -*- coding: utf-8 -*- """ This Script contains the CNN dropout with Spinal fully-connected layer. @author: Dipu """ import torch import torch.nn as nn import torchvision import torchvision.transforms as transforms import random # Device configuration device = torch.device('cuda' if torch.cuda.is_available() else ...
7,532
29.746939
93
py
SpinalNet
SpinalNet-master/MNIST_VGG/EMNIST_digits_VGG_and _SpinalVGG.py
# -*- coding: utf-8 -*- """ This Script contains the default and Spinal VGG code for EMNIST(Digits). This code trains both NNs as two different models. This code randomly changes the learning rate to get a good result. @author: Dipu """ import torch import torchvision import torch.nn as nn import math import torch...
11,675
32.551724
116
py
SpinalNet
SpinalNet-master/MNIST_VGG/KMNIST_VGG_and_SpinalVGG.py
# -*- coding: utf-8 -*- """ This Script contains the default and Spinal VGG code for kMNIST. This code trains both NNs as two different models. This code randomly changes the learning rate to get a good result. @author: Dipu """ import torch import torchvision import torch.nn as nn import math import torch.nn.func...
11,721
32.301136
116
py
SpinalNet
SpinalNet-master/MNIST_VGG/MNIST_VGG_and_SpinalVGG.py
# -*- coding: utf-8 -*- """ This Script contains the default and Spinal VGG code for MNIST. This code trains both NNs as two different models. This code randomly changes the learning rate to get a good result. @author: Dipu """ import torch import torchvision import torch.nn as nn import math import torch.nn.funct...
11,616
32.191429
116
py
SpinalNet
SpinalNet-master/MNIST_VGG/FashionMNIST_VGG_and _SpinalVGG.py
# -*- coding: utf-8 -*- """ This Script contains the default and Spinal VGG code for Fashion-MNIST. This code trains both NNs as two different models. This code randomly changes the learning rate to get a good result. @author: Dipu """ import torch import torchvision import torch.nn as nn import math import torch....
11,734
32.528571
116
py
SpinalNet
SpinalNet-master/MNIST_VGG/EMNIST_letters_VGG_and _SpinalVGG.py
# -*- coding: utf-8 -*- """ This Script contains the default and Spinal VGG code for EMNIST(Letters). This code trains both NNs as two different models. This code randomly changes the learning rate to get a good result. @author: Dipu """ import torch import torchvision import torch.nn as nn import math import torch.n...
11,677
32.751445
116
py
SpinalNet
SpinalNet-master/MNIST_VGG/QMNIST_VGG_and _SpinalVGG.py
# -*- coding: utf-8 -*- """ This Script contains the default and Spinal VGG code for QMNIST. This code trains both NNs as two different models. This code randomly changes the learning rate to get a good result. @author: Dipu """ import torch import torchvision import torch.nn as nn import math import torch.nn.func...
11,636
32.34384
116
py
SpinalNet
SpinalNet-master/MNIST/Arch2_Fashion_MNIST.py
# -*- coding: utf-8 -*- """ This Script contains the SpinalNet Arch2 Fashion MNIST code. @author: Dipu """ import torch import torchvision import numpy as np n_epochs = 200 batch_size_train = 64 batch_size_test = 1000 learning_rate = 0.005 momentum = 0.5 log_interval = 500 first_HL =300 max_accuracy= 0.0 random...
10,213
34.099656
105
py
SpinalNet
SpinalNet-master/MNIST/Arch2_KMNIST.py
# -*- coding: utf-8 -*- """ This Script contains the SpinalNet Arch2 KMNIST code. @author: Dipu """ import torch import torchvision n_epochs = 200 batch_size_train = 64 batch_size_test = 1000 momentum = 0.5 log_interval = 5000 first_HL = 50 random_seed = 1 torch.backends.cudnn.enabled = False torch.manu...
9,711
32.839721
117
py
SpinalNet
SpinalNet-master/MNIST/SpinalNet_MNIST.py
# -*- coding: utf-8 -*- """ This Script contains the SpinalNet MNIST code. It ususlly provides better performance for the same number of epoch. The same code can also be used for KMNIST, QMNIST and FashionMNIST. torchvision.datasets.MNIST needs to be changed to torchvision.datasets.FashionMNIST for FashionMNIST si...
5,560
29.387978
78
py
SpinalNet
SpinalNet-master/MNIST/Arch2_QMNIST.py
# -*- coding: utf-8 -*- """ This Script contains the SpinalNet Arch2 QMNIST code. @author: Dipu """ import torch import torchvision n_epochs = 200 batch_size_train = 64 batch_size_test = 1000 momentum = 0.5 log_interval = 5000 first_HL = 50 prob = 0.5 random_seed = 1 torch.backends.cudnn.enabled = False...
9,751
32.512027
117
py
SpinalNet
SpinalNet-master/MNIST/default_pytorch_EMNIST.py
# -*- coding: utf-8 -*- """ This Script contains the default EMNIST code for comparison. The code is collected from: nextjournal.com/gkoehler/pytorch-mnist As the EMNIST needs split='digits', we make a different file for EMNIST @author: Dipu """ import torch import torchvision n_epochs = 8 batch_size_train = 6...
4,274
28.081633
84
py
SpinalNet
SpinalNet-master/MNIST/Arch2_MNIST.py
# -*- coding: utf-8 -*- """ This Script contains the SpinalNet Arch2 MNIST code. @author: Dipu """ import torch import torchvision import numpy as np n_epochs = 200 batch_size_train = 64 batch_size_test = 1000 learning_rate = 0.01 momentum = 0.5 log_interval = 500 first_HL =30 max_accuracy= 0.0 torch.backends.cud...
10,686
33.253205
105
py
SpinalNet
SpinalNet-master/MNIST/default_pytorch_MNIST.py
# -*- coding: utf-8 -*- """ This Script contains the default MNIST code for comparison. The code is collected from: nextjournal.com/gkoehler/pytorch-mnist The same code can also be used for KMNIST, QMNIST and FashionMNIST. torchvision.datasets.MNIST needs to be changed to torchvision.datasets.FashionMNIST for ...
4,349
28.391892
76
py