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
dataqa
dataqa-master/continuum/validation_tool/catalogue.py
from __future__ import division from functions import axis_lim, flux_at_freq, two_freq_power_law, config2dic, SED import os import glob import numpy as np import pandas as pd from astropy.io import fits as f from astropy.table import Table from astropy.coordinates import SkyCoord from astropy.io.votable import parse_s...
63,782
45.286647
160
py
dataqa
dataqa-master/continuum/validation_tool/radio_image.py
from __future__ import division from functions import remove_extn, get_pixel_area import os import numpy as np from astropy.io import fits as f from astropy.wcs import WCS from astropy.coordinates import SkyCoord from astropy.utils.exceptions import AstropyWarning import warnings from inspect import currentframe, get...
15,725
36.265403
139
py
dataqa
dataqa-master/crosscal/__init__.py
0
0
0
py
dataqa
dataqa-master/crosscal/dish_delay_plot.py
""" Simple function to plot the dish delay. This needs to run separately from the other crosscal plots because it requires all 40 beams to be accessible """ from crosscal_plots import GDSols def get_dish_delay_plots(obs_id, fluxcal, basedir=None): GD = GDSols(obs_id, fluxcal, False, basedir=basedir) GD.get_...
352
22.533333
66
py
dataqa
dataqa-master/crosscal/crosscal_plots.py
#python "module" for QA plots for cross-cal #Will want to plot calibration solutions #also potential for raw and corrected data from __future__ import print_function #load necessary packages import os import numpy as np from astropy.io import ascii import apercal import casacore.tables as pt import logging import mat...
57,674
42.825988
145
py
dataqa
dataqa-master/inspection_plots/__init__.py
0
0
0
py
dataqa
dataqa-master/inspection_plots/inspection_plots.py
# Module with functionality to get the inspection plots for an Apertif observation import numpy as np import os import glob import logging import subprocess logger = logging.getLogger(__name__) FNULL = open(os.devnull, 'w') def get_inspection_plot_list(is_calibrator=False): """ Function to return a list of...
5,046
32.423841
248
py
dataqa
dataqa-master/osa_overview/create_report_nb.py
# version of ../create_report to run as part of the pipeline import os import sys from astropy.table import Table import logging import glob import time import argparse import socket from apercal.libs import lib from dataqa.report import html_report as hp from dataqa.report import html_report_dir as hpd from dataqa.r...
4,528
33.052632
133
py
dataqa
dataqa-master/selfcal/selfcal_maps.py
""" This script contains functionality to plot the selfcal images """ import os from apercal.libs import lib import glob import socket import logging from astropy.io import fits from astropy.wcs import WCS import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import matplotlib.colors as mc logger = ...
10,194
32.983333
128
py
dataqa
dataqa-master/selfcal/selfcal_plots.py
# python "module" for QA plots for cross-cal # Will want to plot calibration solutions # also potential for raw and corrected data # load necessary packages import os import numpy as np import datetime from apercal.subs import readmirlog from apercal.subs import misc import matplotlib.pyplot as plt from matplotlib.pyp...
7,673
44.952096
119
py
dataqa
dataqa-master/selfcal/__init__.py
0
0
0
py
robust-nli
robust-nli-master/src/losses.py
import torch import torch.nn as nn import torch.nn.functional as F def convert_2d_prob_to_3d(prob_dist): prob_dist = torch.cat([(prob_dist[:, 0] / 2.0).view(-1, 1), prob_dist[:, 1].view(-1, 1), (prob_dist[:, 0] / 2.0).view(-1, 1)], dim=1) return prob_dist ...
4,401
35.081967
116
py
robust-nli
robust-nli-master/src/BERT/utils_glue.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a cop...
29,876
37.550968
154
py
robust-nli
robust-nli-master/src/BERT/run_glue.py
""" Finetuning the library models for sequence classification on GLUE (Bert, XLM, XLNet).""" from __future__ import absolute_import, division, print_function import logging import os import random from utils_glue import GLUE_TASKS_NUM_LABELS from eval_utils import load_and_cache_examples, evaluate, get_parser import ...
13,321
42.966997
163
py
robust-nli
robust-nli-master/src/BERT/heuristics_utils.py
# These codes are from the codes for # Right for the Wrong Reasons: Diagnosing Syntactic Heuristics in Natural Language Inference by # Tom McCoy, Ellie Pavlick, Tal Linzen, ACL 2019 def have_lexical_overlap(premise, hypothesis, get_hans_new_features=False): prem_words = [] hyp_words = [] for word in premi...
2,890
28.20202
95
py
robust-nli
robust-nli-master/src/BERT/__init__.py
0
0
0
py
robust-nli
robust-nli-master/src/BERT/utils_bert.py
import torch from torch import nn import sys sys.path.append("../") from torch.nn import CrossEntropyLoss, MSELoss from pytorch_transformers.modeling_bert import BertPreTrainedModel, BertModel from losses import FocalLoss, POELoss, RUBILoss from utils_glue import get_word_similarity_new, get_length_features from mutil...
12,786
48.949219
134
py
robust-nli
robust-nli-master/src/BERT/eval_utils.py
from torch.utils.data import (DataLoader, SequentialSampler, TensorDataset) from os.path import join import numpy as np from utils_glue import (compute_metrics, convert_examples_to_features, processors) import argparse import torch import os import glob import logging from tqdm import tqdm, tran...
25,678
51.620902
135
py
robust-nli
robust-nli-master/src/BERT/mutils.py
import csv import os import torch def write_to_csv(scores, params, outputfile): """ This function writes the parameters and the scores with their names in a csv file. """ # creates the file if not existing. file = open(outputfile, 'a') # If file is empty writes the keys to the file. p...
1,741
30.107143
77
py
robust-nli
robust-nli-master/src/InferSent/data.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import os import numpy as np import torch def get_batch(batch, word_vec, emb_dim=300): # sent in batch in decreasing order ...
3,317
33.926316
84
py
robust-nli
robust-nli-master/src/InferSent/models.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # """ This file contains the definition of encoders used in https://arxiv.org/pdf/1705.02364.pdf """ import time import sys sys....
15,032
34.878282
115
py
robust-nli
robust-nli-master/src/InferSent/train_nli.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # import sys import time import argparse import os import numpy as np import torch from torch.autograd import Variable from d...
14,974
39.582656
130
py
robust-nli
robust-nli-master/src/InferSent/mutils.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # import re import inspect from torch import optim import torch import os import csv def construct_model_name(params, names_par...
4,580
28.941176
79
py
robust-nli
robust-nli-master/data/scripts/nli_hardset.py
import json_lines import os import argparse def process_nli_hardset(datapth, outdir): if not os.path.exists(outdir): os.makedirs(outdir) # Writes data in the file. sentences2 = [] sentences1 = [] labels = [] pair_ids = [] with open(datapth, 'rb') as f: for item in json_line...
1,411
33.439024
103
py
robust-nli
robust-nli-master/data/scripts/glue_diagnostic.py
# This scripts process the SICK-E dataset and # writes it in the format of SNLI dataset. import os import argparse import pandas as pd import numpy as np class GlueDiagnosticDataset(object): def __init__(self, testpath, outputdir): self.testpath = testpath self.outputdir = outputdir # Creat...
2,134
37.125
115
py
robust-nli
robust-nli-master/data/scripts/recast_white.py
import os import argparse import glob class RecastWhiteDataset(object): def __init__(self, datadir, outputdir): self.datadir = datadir self.outputdir = outputdir def writeData(self, lines, fpath): """Writes the given data in the format of each data in one line. """ ...
3,255
40.74359
104
py
robust-nli
robust-nli-master/data/scripts/scitail.py
# This scripts process the Scitail dataset and writes it in the # format of SNLI dataset. import os import json_lines import argparse class SciTailDataset(object): def __init__(self, datadir, outputdir): self.datadir = datadir self.outputdir = outputdir # Creates the output directory if d...
2,217
36.59322
88
py
robust-nli
robust-nli-master/data/scripts/download_glue.py
# The codes are adapted from https://raw.githubusercontent.com/nyu-mll/jiant/master/scripts/download_glue_data.py import os import sys import shutil import argparse import tempfile import urllib.request import zipfile TASKS = ["MNLI", "SNLI"] TASK2PATH = { "MNLI":'https://firebasestorage.googleapis.com/v0/b/mtl-se...
1,366
34.973684
169
py
robust-nli
robust-nli-master/data/scripts/joci.py
import csv import random import os import argparse class JOCIDataset(object): def __init__(self, datadir, outputdir): self.datadir = datadir self.outputdir = outputdir # Creates the output directory if does not exist. if not os.path.exists(outputdir): os.makedirs(outputd...
2,952
33.337209
97
py
robust-nli
robust-nli-master/data/scripts/add_one_rte.py
import os import argparse class AddOneRTEDataset(object): def __init__(self, datadir, outputdir): self.datadir = datadir self.outputdir = outputdir # Creates the output directory if does not exist. if not os.path.exists(outputdir): os.makedirs(outputdir) def writeDa...
3,144
36.891566
105
py
robust-nli
robust-nli-master/data/scripts/sick.py
# This scripts process the SICK-E dataset and # writes it in the format of SNLI dataset. import os import pandas as pd import argparse class SickDataset(object): def __init__(self, datadir, outputdir): self.datadir = datadir self.outputdir = outputdir # Creates the output directory if doe...
2,346
40.175439
97
py
robust-nli
robust-nli-master/data/scripts/qqp.py
import csv import random import os import argparse import numpy as np import csv class QQPDataset(object): def __init__(self, datadir, outputdir): self.datadir = datadir self.outputdir = outputdir if not os.path.exists(outputdir): os.makedirs(outputdir) self.label_dict =...
2,200
34.5
91
py
robust-nli
robust-nli-master/data/scripts/hans.py
import csv import sys from os.path import join import os import argparse def read_tsv(input_file, quotechar=None): """Reads a tab separated value file.""" with open(input_file, "r", encoding="utf-8-sig") as f: reader = csv.reader(f, delimiter="\t", quotechar=quotechar) lines = [] for li...
1,703
31.769231
68
py
robust-nli
robust-nli-master/data/scripts/mpe.py
import csv import random import os import argparse import pandas as pd import numpy as np class MPEDataset(object): def __init__(self, datadir, outputdir): self.datadir = datadir self.outputdir = outputdir if not os.path.exists(outputdir): os.makedirs(outputdir) def writeDa...
2,653
39.212121
115
py
meta-transfer-learning
meta-transfer-learning-main/pytorch/main.py
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ## Created by: Yaoyao Liu ## Tianjin University ## liuyaoyao@tju.edu.cn ## Copyright (c) 2019 ## ## This source code is licensed under the MIT-style license found in the ## LICENSE file in the root directory of this source tree ##++++++++++++++...
4,678
54.702381
133
py
meta-transfer-learning
meta-transfer-learning-main/pytorch/run_pre.py
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ## Created by: Yaoyao Liu ## Tianjin University ## liuyaoyao@tju.edu.cn ## Copyright (c) 2019 ## ## This source code is licensed under the MIT-style license found in the ## LICENSE file in the root directory of this source tree ##++++++++++++++...
1,079
29
75
py
meta-transfer-learning
meta-transfer-learning-main/pytorch/run_meta.py
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ## Created by: Yaoyao Liu ## Tianjin University ## liuyaoyao@tju.edu.cn ## Copyright (c) 2019 ## ## This source code is licensed under the MIT-style license found in the ## LICENSE file in the root directory of this source tree ##++++++++++++++...
1,455
37.315789
110
py
meta-transfer-learning
meta-transfer-learning-main/pytorch/trainer/__init__.py
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ## Created by: Yaoyao Liu ## Tianjin University ## liuyaoyao@tju.edu.cn ## Copyright (c) 2019 ## ## This source code is licensed under the MIT-style license found in the ## LICENSE file in the root directory of this source tree ##++++++++++++++...
380
37.1
75
py
meta-transfer-learning
meta-transfer-learning-main/pytorch/trainer/meta.py
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ## Created by: Yaoyao Liu ## Modified from: https://github.com/Sha-Lab/FEAT ## Tianjin University ## liuyaoyao@tju.edu.cn ## Copyright (c) 2019 ## ## This source code is licensed under the MIT-style license found in the ## LICENSE file in the r...
13,374
44.493197
143
py
meta-transfer-learning
meta-transfer-learning-main/pytorch/trainer/pre.py
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ## Created by: Yaoyao Liu ## Tianjin University ## liuyaoyao@tju.edu.cn ## Copyright (c) 2019 ## ## This source code is licensed under the MIT-style license found in the ## LICENSE file in the root directory of this source tree ##++++++++++++++...
9,314
42.528037
139
py
meta-transfer-learning
meta-transfer-learning-main/pytorch/models/mtl.py
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ## Created by: Yaoyao Liu ## Tianjin University ## liuyaoyao@tju.edu.cn ## Copyright (c) 2019 ## ## This source code is licensed under the MIT-style license found in the ## LICENSE file in the root directory of this source tree ##++++++++++++++...
5,292
38.796992
115
py
meta-transfer-learning
meta-transfer-learning-main/pytorch/models/conv2d_mtl.py
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ## Created by: Yaoyao Liu ## Modified from: https://github.com/pytorch/pytorch ## Tianjin University ## liuyaoyao@tju.edu.cn ## Copyright (c) 2019 ## ## This source code is licensed under the MIT-style license found in the ## LICENSE file in th...
4,195
40.137255
94
py
meta-transfer-learning
meta-transfer-learning-main/pytorch/models/resnet_mtl.py
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ## Created by: Yaoyao Liu ## Modified from: https://github.com/Sha-Lab/FEAT ## Tianjin University ## liuyaoyao@tju.edu.cn ## Copyright (c) 2019 ## ## This source code is licensed under the MIT-style license found in the ## LICENSE file in the r...
6,842
30.246575
90
py
meta-transfer-learning
meta-transfer-learning-main/pytorch/models/__init__.py
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ## Created by: Yaoyao Liu ## Tianjin University ## liuyaoyao@tju.edu.cn ## Copyright (c) 2019 ## ## This source code is licensed under the MIT-style license found in the ## LICENSE file in the root directory of this source tree ##++++++++++++++...
380
37.1
75
py
meta-transfer-learning
meta-transfer-learning-main/pytorch/utils/misc.py
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ## Created by: Yaoyao Liu ## Modified from: https://github.com/Sha-Lab/FEAT ## Tianjin University ## liuyaoyao@tju.edu.cn ## Copyright (c) 2019 ## ## This source code is licensed under the MIT-style license found in the ## LICENSE file in the r...
2,219
24.227273
75
py
meta-transfer-learning
meta-transfer-learning-main/pytorch/utils/gpu_tools.py
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ## Created by: Yaoyao Liu ## Tianjin University ## liuyaoyao@tju.edu.cn ## Copyright (c) 2019 ## ## This source code is licensed under the MIT-style license found in the ## LICENSE file in the root directory of this source tree ##++++++++++++++...
547
31.235294
75
py
meta-transfer-learning
meta-transfer-learning-main/pytorch/utils/__init__.py
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ## Created by: Yaoyao Liu ## Tianjin University ## liuyaoyao@tju.edu.cn ## Copyright (c) 2019 ## ## This source code is licensed under the MIT-style license found in the ## LICENSE file in the root directory of this source tree ##++++++++++++++...
380
37.1
75
py
meta-transfer-learning
meta-transfer-learning-main/pytorch/dataloader/dataset_loader.py
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ## Created by: Yaoyao Liu ## Modified from: https://github.com/Sha-Lab/FEAT ## Tianjin University ## liuyaoyao@tju.edu.cn ## Copyright (c) 2019 ## ## This source code is licensed under the MIT-style license found in the ## LICENSE file in the r...
3,153
37.463415
125
py
meta-transfer-learning
meta-transfer-learning-main/pytorch/dataloader/__init__.py
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ## Created by: Yaoyao Liu ## Tianjin University ## liuyaoyao@tju.edu.cn ## Copyright (c) 2019 ## ## This source code is licensed under the MIT-style license found in the ## LICENSE file in the root directory of this source tree ##++++++++++++++...
380
37.1
75
py
meta-transfer-learning
meta-transfer-learning-main/pytorch/dataloader/samplers.py
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ## Created by: Yaoyao Liu ## Modified from: https://github.com/Sha-Lab/FEAT ## Tianjin University ## liuyaoyao@tju.edu.cn ## Copyright (c) 2019 ## ## This source code is licensed under the MIT-style license found in the ## LICENSE file in the r...
1,381
32.707317
75
py
meta-transfer-learning
meta-transfer-learning-main/tensorflow/main.py
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ## Created by: Yaoyao Liu ## Tianjin University ## liuyaoyao@tju.edu.cn ## Copyright (c) 2019 ## ## This source code is licensed under the MIT-style license found in the ## LICENSE file in the root directory of this source tree ##++++++++++++++...
7,702
51.401361
140
py
meta-transfer-learning
meta-transfer-learning-main/tensorflow/run_experiment.py
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ## Created by: Yaoyao Liu ## Tianjin University ## liuyaoyao@tju.edu.cn ## Copyright (c) 2019 ## ## This source code is licensed under the MIT-style license found in the ## LICENSE file in the root directory of this source tree ##++++++++++++++...
5,436
43.203252
134
py
meta-transfer-learning
meta-transfer-learning-main/tensorflow/trainer/__init__.py
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ## Created by: Yaoyao Liu ## Tianjin University ## liuyaoyao@tju.edu.cn ## Copyright (c) 2019 ## ## This source code is licensed under the MIT-style license found in the ## LICENSE file in the root directory of this source tree ##++++++++++++++...
380
37.1
75
py
meta-transfer-learning
meta-transfer-learning-main/tensorflow/trainer/meta.py
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ## Created by: Yaoyao Liu ## Modified from: https://github.com/cbfinn/maml ## Tianjin University ## liuyaoyao@tju.edu.cn ## Copyright (c) 2019 ## ## This source code is licensed under the MIT-style license found in the ## LICENSE file in the ro...
16,927
51.571429
138
py
meta-transfer-learning
meta-transfer-learning-main/tensorflow/trainer/pre.py
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ## Created by: Yaoyao Liu ## Modified from: https://github.com/cbfinn/maml ## Tianjin University ## liuyaoyao@tju.edu.cn ## Copyright (c) 2019 ## ## This source code is licensed under the MIT-style license found in the ## LICENSE file in the ro...
3,972
39.958763
102
py
meta-transfer-learning
meta-transfer-learning-main/tensorflow/models/resnet18.py
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ## Created by: Yaoyao Liu ## Modified from: https://github.com/cbfinn/maml ## Tianjin University ## liuyaoyao@tju.edu.cn ## Copyright (c) 2019 ## ## This source code is licensed under the MIT-style license found in the ## LICENSE file in the ro...
17,202
49.89645
129
py
meta-transfer-learning
meta-transfer-learning-main/tensorflow/models/resnet12.py
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ## Created by: Yaoyao Liu ## Modified from: https://github.com/cbfinn/maml ## Tianjin University ## liuyaoyao@tju.edu.cn ## Copyright (c) 2019 ## ## This source code is licensed under the MIT-style license found in the ## LICENSE file in the ro...
12,316
50.320833
129
py
meta-transfer-learning
meta-transfer-learning-main/tensorflow/models/pre_model.py
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ## Created by: Yaoyao Liu ## Tianjin University ## liuyaoyao@tju.edu.cn ## Copyright (c) 2019 ## ## This source code is licensed under the MIT-style license found in the ## LICENSE file in the root directory of this source tree ##++++++++++++++...
3,134
47.230769
142
py
meta-transfer-learning
meta-transfer-learning-main/tensorflow/models/__init__.py
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ## Created by: Yaoyao Liu ## Tianjin University ## liuyaoyao@tju.edu.cn ## Copyright (c) 2019 ## ## This source code is licensed under the MIT-style license found in the ## LICENSE file in the root directory of this source tree ##++++++++++++++...
380
37.1
75
py
meta-transfer-learning
meta-transfer-learning-main/tensorflow/models/meta_model.py
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ## Created by: Yaoyao Liu ## Modified from: https://github.com/cbfinn/maml ## Tianjin University ## liuyaoyao@tju.edu.cn ## Copyright (c) 2019 ## ## This source code is licensed under the MIT-style license found in the ## LICENSE file in the ro...
12,839
54.107296
142
py
meta-transfer-learning
meta-transfer-learning-main/tensorflow/data_generator/meta_data_generator.py
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ## Created by: Yaoyao Liu ## Modified from: https://github.com/cbfinn/maml ## Tianjin University ## liuyaoyao@tju.edu.cn ## Copyright (c) 2019 ## ## This source code is licensed under the MIT-style license found in the ## LICENSE file in the ro...
7,979
45.941176
141
py
meta-transfer-learning
meta-transfer-learning-main/tensorflow/data_generator/__init__.py
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ## Created by: Yaoyao Liu ## Tianjin University ## liuyaoyao@tju.edu.cn ## Copyright (c) 2019 ## ## This source code is licensed under the MIT-style license found in the ## LICENSE file in the root directory of this source tree ##++++++++++++++...
380
37.1
75
py
meta-transfer-learning
meta-transfer-learning-main/tensorflow/data_generator/pre_data_generator.py
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ## Created by: Yaoyao Liu ## Modified from: https://github.com/cbfinn/maml ## Tianjin University ## liuyaoyao@tju.edu.cn ## Copyright (c) 2019 ## ## This source code is licensed under the MIT-style license found in the ## LICENSE file in the ro...
2,850
43.546875
189
py
meta-transfer-learning
meta-transfer-learning-main/tensorflow/utils/misc.py
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ## Created by: Yaoyao Liu ## Modified from: https://github.com/cbfinn/maml ## Tianjin University ## liuyaoyao@tju.edu.cn ## Copyright (c) 2019 ## ## This source code is licensed under the MIT-style license found in the ## LICENSE file in the ro...
10,805
33.634615
100
py
meta-transfer-learning
meta-transfer-learning-main/tensorflow/utils/__init__.py
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ## Created by: Yaoyao Liu ## Tianjin University ## liuyaoyao@tju.edu.cn ## Copyright (c) 2019 ## ## This source code is licensed under the MIT-style license found in the ## LICENSE file in the root directory of this source tree ##++++++++++++++...
380
37.1
75
py
adventures-in-ml-code
adventures-in-ml-code-master/tf_dataset_tutorial.py
import tensorflow as tf import numpy as np from sklearn.datasets import load_digits def simple_dataset_with_error(): x = np.arange(0, 10) # create dataset object from the numpy array dx = tf.data.Dataset.from_tensor_slices(x) # create a one-shot iterator iterator = dx.make_one_shot_iterator() #...
5,550
39.816176
116
py
adventures-in-ml-code
adventures-in-ml-code-master/lstm_tutorial.py
import tensorflow as tf import numpy as np import collections import os import argparse import datetime as dt """To run this code, you'll need to first download and extract the text dataset from here: http://www.fit.vutbr.cz/~imikolov/rnnlm/simple-examples.tgz. Change the data_path variable below to your local...
11,368
42.895753
117
py
adventures-in-ml-code
adventures-in-ml-code-master/keras_word2vec.py
from keras.models import Model from keras.layers import Input, Dense, Reshape, merge from keras.layers.embeddings import Embedding from keras.preprocessing.sequence import skipgrams from keras.preprocessing import sequence import urllib import collections import os import zipfile import numpy as np import tensorflow ...
5,397
34.513158
101
py
adventures-in-ml-code
adventures-in-ml-code-master/convolutional_neural_network_tutorial.py
import tensorflow as tf import numpy as np from tensorflow.examples.tutorials.mnist import input_data def run_cnn(): mnist = input_data.read_data_sets("MNIST_data/", one_hot=True) # Python optimisation variables learning_rate = 0.0001 epochs = 10 batch_size = 50 # declare the training data p...
5,605
46.508475
120
py
adventures-in-ml-code
adventures-in-ml-code-master/dueling_q_tf2_atari.py
import gym import tensorflow as tf from tensorflow import keras import random import numpy as np import datetime as dt import imageio STORE_PATH = 'C:\\Users\\Andy\\TensorFlowBook\\TensorBoard' MAX_EPSILON = 1 MIN_EPSILON = 0.1 EPSILON_MIN_ITER = 500000 GAMMA = 0.99 BATCH_SIZE = 32 TAU = 0.08 POST_PROCESS_IMAGE_SIZE =...
8,874
39.711009
125
py
adventures-in-ml-code
adventures-in-ml-code-master/policy_gradient_reinforce_tf2.py
import gym import tensorflow as tf from tensorflow import keras import numpy as np import datetime as dt STORE_PATH = '/Users/andrewthomas/Adventures in ML/TensorFlowBook/TensorBoard/PolicyGradientCartPole' GAMMA = 0.95 env = gym.make("CartPole-v0") state_size = 4 num_actions = env.action_space.n network = keras.Seq...
2,344
34
116
py
adventures-in-ml-code
adventures-in-ml-code-master/r_learning_tensorflow.py
import gym import numpy as np import tensorflow as tf import matplotlib.pylab as plt import random import math MAX_EPSILON = 1 MIN_EPSILON = 0.01 LAMBDA = 0.0001 GAMMA = 0.99 BATCH_SIZE = 50 class Model: def __init__(self, num_states, num_actions, batch_size): self._num_states = num_states self._n...
7,025
31.37788
94
py
adventures-in-ml-code
adventures-in-ml-code-master/sum_tree_intro.py
import numpy as np class Node: def __init__(self, left, right, is_leaf: bool = False, idx = None): self.left = left self.right = right self.is_leaf = is_leaf if not self.is_leaf: self.value = self.left.value + self.right.value self.parent = None self.idx ...
2,459
27.941176
111
py
adventures-in-ml-code
adventures-in-ml-code-master/tf_queuing.py
import tensorflow as tf data_path = "C:\\Users\Andy\PycharmProjects\data\cifar-10-batches-bin\\" def FIFO_queue_demo_no_coord(): # first let's create a simple random normal Tensor to act as dummy input data # this operation should be run more than once, everytime the queue needs filling # back up. Howev...
10,026
41.487288
110
py
adventures-in-ml-code
adventures-in-ml-code-master/vanishing_gradient.py
from tensorflow.examples.tutorials.mnist import input_data import tensorflow as tf base_path = "C:\\Users\\Andy\\PycharmProjects\\Tensorboard\\" class Model(object): def __init__(self, input_size, label_size, activation, num_layers=6, hidden_size=10): self._input_size = input_size ...
4,262
49.75
104
py
adventures-in-ml-code
adventures-in-ml-code-master/per_duelingq_spaceinv_tf2.py
import gym import tensorflow as tf from tensorflow import keras import random import numpy as np import datetime as dt import imageio import os # STORE_PATH = '/Users/andrewthomas/Adventures in ML/TensorFlowBook/TensorBoard' # STORE_PATH = "tensorboard" STORE_PATH = "C:\\Users\\Andy\\TensorFlowBook\\TensorBoard" MAX_E...
13,766
40.844985
165
py
adventures-in-ml-code
adventures-in-ml-code-master/cntk_tutorial.py
import os os.environ['PATH'] = "C:\\Users\Andy\Anaconda2\envs\TensorFlow" + ';' + os.environ['PATH'] import cntk as C from cntk.train import Trainer from cntk.io import MinibatchSource, CTFDeserializer, StreamDef, StreamDefs from cntk.learners import adadelta, learning_rate_schedule, UnitType from cntk.ops import relu...
3,759
33.495413
90
py
adventures-in-ml-code
adventures-in-ml-code-master/gensim_word2vec.py
import gensim from gensim.models import word2vec import logging from keras.layers import Input, Embedding, merge from keras.models import Model import tensorflow as tf import numpy as np import urllib.request import os import zipfile vector_dim = 300 root_path = "C:\\Users\Andy\PycharmProjects\\adventures-in-ml-cod...
7,078
38.327778
120
py
adventures-in-ml-code
adventures-in-ml-code-master/a2c_tf2_cartpole.py
import tensorflow as tf from tensorflow import keras import numpy as np import gym import datetime as dt import os os.environ['KMP_DUPLICATE_LIB_OK']='True' STORE_PATH = '/Users/andrewthomas/Adventures in ML/TensorFlowBook/TensorBoard/A2CCartPole' CRITIC_LOSS_WEIGHT = 0.5 ACTOR_LOSS_WEIGHT = 1.0 ENTROPY_LOSS_WEIGHT ...
4,312
32.96063
118
py
adventures-in-ml-code
adventures-in-ml-code-master/pytorch_nn.py
import torch from torch.autograd import Variable import torch.nn as nn import torch.nn.functional as F import torch.optim as optim from torchvision import datasets, transforms def simple_gradient(): # print the gradient of 2x^2 + 5x x = Variable(torch.ones(2, 2) * 2, requires_grad=True) z = 2 * (x * x) + ...
3,316
33.915789
81
py
adventures-in-ml-code
adventures-in-ml-code-master/tensor_flow_tutorial.py
import tensorflow as tf import numpy as np import datetime as dt from tensorflow.keras.datasets import mnist STORE_PATH = '/Users/andrewthomas/Adventures in ML/TensorBoard' def run_simple_graph(): # create TensorFlow variables const = tf.Variable(2.0, name="const") b = tf.Variable(2.0, name='b') c = t...
4,411
32.424242
103
py
adventures-in-ml-code
adventures-in-ml-code-master/double_q_tensorflow2.py
import gym import tensorflow as tf from tensorflow import keras import random import numpy as np import datetime as dt import math STORE_PATH = '/Users/andrewthomas/Adventures in ML/TensorFlowBook/TensorBoard' MAX_EPSILON = 1 MIN_EPSILON = 0.01 LAMBDA = 0.0005 GAMMA = 0.95 BATCH_SIZE = 32 TAU = 0.08 RANDOM_REWARD_STD ...
4,711
32.41844
118
py
adventures-in-ml-code
adventures-in-ml-code-master/keras_lstm.py
from __future__ import print_function import collections import os import tensorflow as tf from keras.models import Sequential, load_model from keras.layers import Dense, Activation, Embedding, Dropout, TimeDistributed from keras.layers import LSTM from keras.optimizers import Adam from keras.utils import to_categorica...
7,148
39.619318
109
py
adventures-in-ml-code
adventures-in-ml-code-master/dueling_q_tensorflow2.py
import gym import tensorflow as tf from tensorflow import keras import random import numpy as np import datetime as dt import math STORE_PATH = '/Users/andrewthomas/Adventures in ML/TensorFlowBook/TensorBoard' MAX_EPSILON = 1 MIN_EPSILON = 0.01 EPSILON_MIN_ITER = 5000 DELAY_TRAINING = 300 GAMMA = 0.95 BATCH_SIZE = 32 ...
6,519
35.629213
118
py
adventures-in-ml-code
adventures-in-ml-code-master/tf_visualization.py
import tensorflow as tf import numpy as np from tensorflow.keras.datasets import mnist STORE_PATH = 'C:\\Users\\Andy\\TensorFlowBook\\TensorBoard' def get_batch(x_data, y_data, batch_size): idxs = np.random.randint(0, len(y_data), batch_size) return x_data[idxs,:,:], y_data[idxs] def nn_example(): (x_tra...
4,100
44.065934
113
py
adventures-in-ml-code
adventures-in-ml-code-master/ppo_tf2_cartpole.py
import tensorflow as tf from tensorflow import keras import tensorflow_probability as tfp import numpy as np import gym import datetime as dt STORE_PATH = 'C:\\Users\\andre\\TensorBoard\\PPOCartpole' CRITIC_LOSS_WEIGHT = 0.5 ENTROPY_LOSS_WEIGHT = 0.01 ENT_DISCOUNT_RATE = 0.995 BATCH_SIZE = 64 GAMMA = 0.99 CLIP_VALUE ...
6,351
35.297143
119
py
adventures-in-ml-code
adventures-in-ml-code-master/keras_eager_tf_2.py
import tensorflow as tf from tensorflow import keras import datetime as dt tf.enable_eager_execution() (x_train, y_train), (x_test, y_test) = keras.datasets.cifar10.load_data() # prepare training data train_dataset = tf.data.Dataset.from_tensor_slices((x_train, y_train)).batch(32).shuffle(10000) train_dataset = trai...
3,037
44.343284
128
py
adventures-in-ml-code
adventures-in-ml-code-master/tf_word2vec.py
import urllib.request import collections import math import os import random import zipfile import datetime as dt import numpy as np import tensorflow as tf def maybe_download(filename, url, expected_bytes): """Download a file if not present, and make sure it's the right size.""" if not os.path.exists(filena...
8,637
38.263636
123
py
adventures-in-ml-code
adventures-in-ml-code-master/r_learning_python.py
import gym import numpy as np from keras.models import Sequential from keras.layers import Dense, InputLayer import matplotlib.pylab as plt env = gym.make('NChain-v0') def naive_sum_reward_agent(env, num_episodes=500): # this is the table that will hold our summated rewards for # each action in each state ...
4,424
32.522727
94
py
adventures-in-ml-code
adventures-in-ml-code-master/conv_net_py_torch.py
import torch import torch.nn as nn from torch.utils.data import DataLoader import torchvision.transforms as transforms import torchvision.datasets from bokeh.plotting import figure from bokeh.io import show from bokeh.models import LinearAxis, Range1d import numpy as np # Hyperparameters num_epochs = 6 num_classes = ...
3,793
32.575221
102
py
adventures-in-ml-code
adventures-in-ml-code-master/keras_cnn.py
from __future__ import print_function import keras from keras.datasets import mnist from keras.layers import Dense, Flatten from keras.layers import Conv2D, MaxPooling2D from keras.models import Sequential import matplotlib.pylab as plt batch_size = 128 num_classes = 10 epochs = 10 # input image dimensions img_x, img...
2,477
31.181818
96
py
adventures-in-ml-code
adventures-in-ml-code-master/neural_network_tutorial.py
from sklearn.datasets import load_digits from sklearn.preprocessing import StandardScaler from sklearn.model_selection import train_test_split from sklearn.metrics import accuracy_score import numpy as np import numpy.random as r import matplotlib.pyplot as plt def convert_y_to_vect(y): y_vect = np.zeros((len(y),...
4,528
31.582734
99
py
adventures-in-ml-code
adventures-in-ml-code-master/weight_init_tensorflow.py
import tensorflow as tf import os from tensorflow.examples.tutorials.mnist import input_data from functools import partial base_path = "C:\\Users\\Andy\\PycharmProjects\\Tensorboard\\weights\\" def maybe_create_folder_structure(sub_folders): for fold in sub_folders: if not os.path.isdir(base_path + fold):...
6,524
51.620968
110
py
ModProp
ModProp-main/setup.py
""" The Clear BSD License Copyright (c) 2019 the LSNN team, institute for theoretical computer science, TU Graz All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted (subject to the limitations in the disclaimer below) provided that the following condition...
3,706
53.514706
844
py
ModProp
ModProp-main/bin/rewiring_tools_NP2.py
""" Code modified to enable dense connectivity when Dale's law is enforced and for type-specific approximation of feedback weights for ModProp gradient approximation via automatic differentiation Modified from https://github.com/IGITUGraz/LSNN-official with the following copyright message retained from ...
29,033
46.286645
844
py
ModProp
ModProp-main/bin/neuron_models.py
""" Code modified for rate-based neurons (ReLU activation) and for activation derivative approximation (for nonlocal terms only) for ModProp via automatic differentiation The overall ModProp framework proposed is "communicating the credit information via cell-type-specific neuromodulators and processing it at...
35,594
44.634615
844
py
ModProp
ModProp-main/bin/delayedXOR_task.py
''' Code adapted for training a RNN using ModProp to perform a delayed XOR task. The overall ModProp framework proposed is "communicating the credit information via cell-type-specific neuromodulators and processing it at the receiving cells via pre-determined temporal filtering taps." Remarks: - If yo...
24,338
45.715931
844
py
ModProp
ModProp-main/bin/plot_curves.py
# -*- coding: utf-8 -*- """ Code for plotting the learning curves of saved runs """ import sys import matplotlib.pyplot as plt import numpy as np import tensorflow as tf from file_saver_dumper_no_h5py import save_file, load_file, get_storage_path_reference import json import os ## Setup SMALL_SIZE = 12 MEDIUM_SIZE =...
3,600
33.961165
121
py
ModProp
ModProp-main/lsnn/spiking_models.py
""" The Clear BSD License Copyright (c) 2019 the LSNN team, institute for theoretical computer science, TU Graz All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted (subject to the limitations in the disclaimer below) provided that the following condition...
21,033
39.922179
844
py
ModProp
ModProp-main/lsnn/__init__.py
0
0
0
py