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 |
|---|---|---|---|---|---|---|
B-SOID | B-SOID-master/bsoid_app/analysis_subroutines/trajectory_analysis.py | import h5py
import matplotlib.colors as mcolors
import matplotlib.pyplot as plt
import pandas as pd
import streamlit as st
from analysis_subroutines.analysis_scripts.trajectory_plot import *
class trajectory:
def __init__(self, working_dir, prefix, soft_assignments, framerate, filenames, new_data, new_predictio... | 6,324 | 54.973451 | 116 | py |
B-SOID | B-SOID-master/bsoid_app/analysis_subroutines/video_analysis.py | import ffmpeg
import streamlit as st
from analysis_subroutines.analysis_utilities.visuals import *
from analysis_subroutines.analysis_scripts.umap_clustering_plot import plot_enhanced_umap
class bsoid_video:
def __init__(self, working_dir, prefix, features, sampled_features,
sampled_embeddings,... | 5,592 | 56.659794 | 119 | py |
B-SOID | B-SOID-master/bsoid_app/analysis_subroutines/__init__.py | 0 | 0 | 0 | py | |
B-SOID | B-SOID-master/bsoid_app/analysis_subroutines/directed_graph_analysis.py | import matplotlib as mpl
import matplotlib.pyplot as plt
import networkx as nx
import numpy as np
import streamlit as st
from analysis_subroutines.analysis_utilities import statistics
class directed_graph:
def __init__(self, working_dir, prefix, soft_assignments, folders, folder, new_predictions):
st.su... | 3,146 | 44.608696 | 119 | py |
B-SOID | B-SOID-master/bsoid_app/analysis_subroutines/kinematics_analysis.py | import h5py
import matplotlib.colors as mcolors
import pandas as pd
import streamlit as st
from analysis_subroutines.analysis_scripts.extract_kinematics import *
from analysis_subroutines.analysis_utilities.visuals import *
from analysis_subroutines.analysis_utilities.save_data import results
from analysis_subroutines... | 10,088 | 57.656977 | 119 | py |
B-SOID | B-SOID-master/bsoid_app/analysis_subroutines/machine_performance.py | import matplotlib.colors as mcolors
import streamlit as st
from analysis_subroutines.analysis_scripts.kfold_accuracy import *
from analysis_subroutines.analysis_utilities.load_data import load_sav
from analysis_subroutines.analysis_utilities.save_data import results
from analysis_subroutines.analysis_utilities.visuals... | 4,166 | 50.444444 | 110 | py |
B-SOID | B-SOID-master/bsoid_app/analysis_subroutines/analysis_utilities/processing.py | import re
from operator import itemgetter
import numpy as np
import pandas as pd
def convert_int(s):
""" Converts digit string to integer
"""
if s.isdigit():
return int(s)
else:
return s
def alphanum_key(s):
""" Turn a string into a list of string and number chunks.
"z23... | 972 | 20.622222 | 80 | py |
B-SOID | B-SOID-master/bsoid_app/analysis_subroutines/analysis_utilities/statistics.py | import numpy as np
import pandas as pd
def transition_matrix(labels, n):
tm = [[0] * n for _ in range(n)]
for (i, j) in zip(labels, labels[1:]):
tm[i][j] += 1
tm_df = pd.DataFrame(tm)
tm_array = np.array(tm)
tm_norm = tm_array / tm_array.sum(axis=1)
return tm_array, tm_df, tm_norm
de... | 5,098 | 36.218978 | 103 | py |
B-SOID | B-SOID-master/bsoid_app/analysis_subroutines/analysis_utilities/visuals.py | import colorsys
import glob
import os
import subprocess
import matplotlib as mpl
import matplotlib.colors as mc
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
from matplotlib.axes._axes import _log as matplotlib_axes_logger
from matplotlib.pyplot import figure
from analysis_subroutines.analy... | 13,577 | 42.941748 | 120 | py |
B-SOID | B-SOID-master/bsoid_app/analysis_subroutines/analysis_utilities/load_data.py | import os
import joblib
import scipy.io
def load_mat(file):
return scipy.io.loadmat(file)
def load_sav(path, name, fname):
with open(os.path.join(path, str.join('', (name, '_', fname, '.sav'))), 'rb') as fr:
data = joblib.load(fr)
return [i for i in data]
class appdata:
def __init__(self... | 1,576 | 28.754717 | 103 | py |
B-SOID | B-SOID-master/bsoid_app/analysis_subroutines/analysis_utilities/__init__.py | 0 | 0 | 0 | py | |
B-SOID | B-SOID-master/bsoid_app/analysis_subroutines/analysis_utilities/save_data.py | import os
import joblib
class results:
def __init__(self, path, name):
self.path = path
self.name = name
def save_sav(self, datalist, file):
with open(os.path.join(self.path, str.join('', (self.name, '_', file, '.sav'))), 'wb') as f:
joblib.dump(datalist, f)
| 308 | 19.6 | 100 | py |
B-SOID | B-SOID-master/bsoid_app/analysis_subroutines/analysis_utilities/cache_workspace.py | import os
import joblib
import streamlit as st
@st.cache
def load_data(path, name):
with open(os.path.join(path, str.join('', (name, '_data.sav'))), 'rb') as fr:
_, _, framerate, _, _, _, _, _ = joblib.load(fr)
with open(os.path.join(path, str.join('', (name, '_feats.sav'))), 'rb') as fr:
fea... | 983 | 45.857143 | 102 | py |
B-SOID | B-SOID-master/bsoid_app/analysis_subroutines/analysis_scripts/kfold_accuracy.py | import getopt
import sys
from ast import literal_eval
import numpy as np
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import KFold
from analysis_subroutines.analysis_utilities.load_data import appdata
from analysis_subroutines.analysis_utilities.processing import reorganize_group_o... | 2,607 | 33.315789 | 94 | py |
B-SOID | B-SOID-master/bsoid_app/analysis_subroutines/analysis_scripts/extract_kinematics.py | import getopt
import glob
import os
import subprocess
import sys
from ast import literal_eval
import matplotlib.pyplot as plt
import numpy as np
from scipy.signal import find_peaks
from tqdm import tqdm
from analysis_subroutines.analysis_utilities.load_data import appdata
from analysis_subroutines.analysis_utilities.... | 11,163 | 44.016129 | 111 | py |
B-SOID | B-SOID-master/bsoid_app/analysis_subroutines/analysis_scripts/trajectory_plot.py | import getopt
import sys
from ast import literal_eval
import numpy as np
from analysis_subroutines.analysis_utilities.load_data import appdata
from analysis_subroutines.analysis_utilities.visuals import plot_trajectory
def limb_trajectory(path, name, animal_idx, bp, t_range):
appdata_ = appdata(path, name)
... | 2,938 | 33.988095 | 123 | py |
B-SOID | B-SOID-master/bsoid_app/analysis_subroutines/analysis_scripts/umap_clustering_plot.py | import getopt
import os
import sys
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.axes._axes import _log as matplotlib_axes_logger
from matplotlib.pyplot import figure
from analysis_subroutines.analysis_utilities.load_data import appdata
matplotlib_axes_logger.setLevel('ERROR')
def plot_enhance... | 2,917 | 32.54023 | 105 | py |
B-SOID | B-SOID-master/bsoid_app/analysis_subroutines/analysis_scripts/accuracy_boxplot.py | import getopt
import sys
from ast import literal_eval
from analysis_utilities.load_data import load_sav
from analysis_utilities.visuals import plot_accuracy_boxplot
def main(argv):
path = None
name = None
vname = None
algorithm = None
c = None
fig_format = None
outpath = None
options,... | 1,585 | 28.924528 | 101 | py |
B-SOID | B-SOID-master/bsoid_app/analysis_subroutines/analysis_scripts/coherence_boxplot.py | import getopt
import sys
import numpy as np
from analysis_utilities.load_data import load_sav
from analysis_utilities.visuals import plot_coherence_boxplot
def main(argv):
path = None
name = None
vname = None
algorithm = None
c = None
fig_format = None
outpath = None
options, args = ... | 1,551 | 27.740741 | 103 | py |
B-SOID | B-SOID-master/bsoid_app/analysis_subroutines/analysis_scripts/pose_relationships_hist.py | import getopt
import itertools
import sys
from ast import literal_eval
from collections import OrderedDict
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.pyplot import figure
from analysis_utilities.load_data import appdata
def plot_pose_relationships(path, name, order, fig_size, fig_format, out... | 6,576 | 51.616 | 117 | py |
B-SOID | B-SOID-master/bsoid_app/analysis_subroutines/analysis_scripts/frameshift_coherence.py | import getopt
import sys
from ast import literal_eval
import numpy as np
from analysis_utilities.load_data import appdata
from analysis_utilities.processing import reorganize_group_order
from analysis_utilities.save_data import results
def generate_coherence(path, name, fps, target_fps, frame_skips, animal_index, t... | 3,054 | 34.523256 | 113 | py |
B-SOID | B-SOID-master/bsoid_app/analysis_subroutines/analysis_scripts/__init__.py | 0 | 0 | 0 | py | |
B-SOID | B-SOID-master/bsoid_app/analysis_subroutines/analysis_scripts/kinematics_cdf.py | import getopt
import sys
from ast import literal_eval
import numpy as np
from analysis_subroutines.analysis_utilities.load_data import load_sav
from analysis_utilities.visuals import plot_kinematics_cdf
def main(argv):
path = None
name = None
var = None
vname = None
bp = None
c = None
x_... | 2,559 | 30.604938 | 112 | py |
B-SOID | B-SOID-master/bsoid_app/config/global_config.py | UMAP_PARAMS = {
'min_dist': 0.0,
'random_state': 42,
}
HDBSCAN_PARAMS = {
'min_samples': 1
}
| 105 | 12.25 | 23 | py |
B-SOID | B-SOID-master/bsoid_app/config/__init__.py | from bsoid_app.config.global_config import * | 44 | 44 | 44 | py |
B-SOID | B-SOID-master/bsoid_app/bsoid_utilities/load_css.py | import streamlit as st
def local_css(file_name):
with open(file_name) as f:
st.markdown('<style>{}</style>'.format(f.read()), unsafe_allow_html=True)
| 164 | 22.571429 | 81 | py |
B-SOID | B-SOID-master/bsoid_app/bsoid_utilities/load_json.py | import numpy as np
import pandas as pd
from tqdm import tqdm
def read_json_single(filename):
pose_names = {0: "Nose", 1: "Neck", 2: "RShoulder", 3: "RElbow", 4: "RWrist", 5: "LShoulder",
6: "LElbow", 7: "LWrist", 8: "MidHip", 9: "RHip", 10: "RKnee", 11: "RAnkle", 12: "LHip",
13... | 3,497 | 52 | 112 | py |
B-SOID | B-SOID-master/bsoid_app/bsoid_utilities/load_workspace.py | import streamlit as st
import os
import joblib
@st.cache
def load_data(path, name):
with open(os.path.join(path, str.join('', (name, '_data.sav'))), 'rb') as fr:
data = joblib.load(fr)
return [i for i in data]
def query_workspace():
working_dir = st.sidebar.text_input('Enter the prior B-SOiD wor... | 2,410 | 29.518987 | 101 | py |
B-SOID | B-SOID-master/bsoid_app/bsoid_utilities/likelihoodprocessing.py | """
likelihood processing analysis_utilities
Forward fill low likelihood (x,y)
"""
import glob
import re
import numpy as np
import pandas as pd
from tqdm import tqdm
def boxcar_center(a, n):
a1 = pd.Series(a)
moving_avg = np.array(a1.rolling(window=n, min_periods=1, center=True).mean())
return moving_a... | 6,593 | 33.52356 | 107 | py |
B-SOID | B-SOID-master/bsoid_app/bsoid_utilities/bsoid_classification.py | import itertools
import math
import numpy as np
from bsoid_app.bsoid_utilities.likelihoodprocessing import boxcar_center
def bsoid_extract(data, fps):
"""
Extracts features based on (x,y) positions
:param data: list, csv data
:param fps: scalar, input for camera frame-rate
:return f_10fps: 2D ar... | 3,998 | 42.467391 | 120 | py |
B-SOID | B-SOID-master/bsoid_app/bsoid_utilities/statistics.py | """
Summary statistics
"""
from bsoid_app.analysis_subroutines.analysis_utilities.statistics import *
| 106 | 10.888889 | 74 | py |
B-SOID | B-SOID-master/bsoid_app/bsoid_utilities/videoprocessing.py | import os
import random
import sys
import cv2
import imageio
import numpy as np
from skimage.transform import rescale
from tqdm import tqdm
from bsoid_app.bsoid_utilities.likelihoodprocessing import sort_nicely
from bsoid_app.bsoid_utilities.statistics import repeating_numbers
def create_labeled_vid(labels, crit, c... | 2,845 | 33.707317 | 115 | py |
B-SOID | B-SOID-master/bsoid_app/bsoid_utilities/visuals.py | import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns
import streamlit as st
from matplotlib.axes._axes import _log as matplotlib_axes_logger
from sklearn.metrics import plot_confusion_matrix
matplotlib_axes_logger.setLevel('ERROR')
def plot_bar(sub_threshold):
st.write('If... | 3,358 | 34.357895 | 110 | py |
B-SOID | B-SOID-master/bsoid_app/bsoid_utilities/__init__.py | 0 | 0 | 0 | py | |
B-SOID | B-SOID-master/bsoid_py/main.py | """
A master that runs BOTH
1. Training a unsupervised machine learning model based on patterns in spatio-temporal (x,y) changes.
2. Predicting new behaviors using (x,y) based on learned classifier.
"""
import os
import time
import joblib
import numpy as np
import pandas as pd
from bsoid_py.config import *
def bui... | 8,580 | 58.17931 | 119 | py |
B-SOID | B-SOID-master/bsoid_py/classify.py | """
Classify behaviors based on (x,y) using trained B-SOiD behavioral model.
B-SOiD behavioral model has been developed using bsoid_py.main.build()
"""
import math
import numpy as np
from bsoid_py.utils import videoprocessing
from bsoid_py.utils.likelihoodprocessing import boxcar_center
from bsoid_py.utils.visuals i... | 8,818 | 50.573099 | 117 | py |
B-SOID | B-SOID-master/bsoid_py/__init__.py | 0 | 0 | 0 | py | |
B-SOID | B-SOID-master/bsoid_py/train.py | """
Based on the natural statistics of the mouse configuration using (x,y) positions,
we distill information down to 3 dimensions and run pattern recognition.
Then, we utilize these output and original feature space to train a B-SOiD behavioral model.
"""
import math
import numpy as np
from sklearn import mixture, sv... | 14,811 | 53.859259 | 117 | py |
B-SOID | B-SOID-master/bsoid_py/config/GLOBAL_CONFIG.py | ################### THINGS YOU PROBABLY DONT'T WANT TO CHANGE ###################
import logging
import sys
logging.basicConfig(
format='%(asctime)s %(levelname)-8s %(message)s',
level='INFO',
datefmt='%Y-%m-%d %H:%M:%S',
stream=sys.stdout)
# EM_GMM parameters
EMGMM_PARAMS = {
'n_components': 30,... | 1,180 | 31.805556 | 86 | py |
B-SOID | B-SOID-master/bsoid_py/config/LOCAL_CONFIG.py | ################### THINGS YOU MAY WANT TO CHANGE ###################
BASE_PATH = '/Users/ahsu/B-SOID/datasets' # Base directory path.
TRAIN_FOLDERS = ['/Train1'] # Data folders used to training neural network.
PREDICT_FOLDERS = ['/Data1'] # Data folders, can contain the same as training or new data for consistency... | 1,744 | 40.547619 | 107 | py |
B-SOID | B-SOID-master/bsoid_py/config/__init__.py | from bsoid_py.config.LOCAL_CONFIG import *
from bsoid_py.config.GLOBAL_CONFIG import * | 86 | 42.5 | 43 | py |
B-SOID | B-SOID-master/bsoid_py/utils/likelihoodprocessing.py | """
likelihood processing utilities
Forward fill low likelihood (x,y)
"""
import glob
import re
import numpy as np
from tqdm import tqdm
from bsoid_py.utils.visuals import *
def boxcar_center(a, n):
a1 = pd.Series(a)
moving_avg = np.array(a1.rolling(window=n, min_periods=1, center=True).mean())
return... | 4,618 | 31.076389 | 108 | py |
B-SOID | B-SOID-master/bsoid_py/utils/statistics.py | """
Summary statistics
"""
import os
import time
import numpy as np
import pandas as pd
from bsoid_py.config import *
def transition_matrix(labels):
"""
:param labels: 1D array, predicted labels
:return df_tm: object, transition matrix data frame
"""
n = 1 + max(labels)
tm = [[0] * n for _ ... | 4,417 | 36.12605 | 103 | py |
B-SOID | B-SOID-master/bsoid_py/utils/videoprocessing.py | """
Extracting frames from videos
"""
import glob
import random
import numpy as np
import cv2
from tqdm import tqdm
from bsoid_py.utils.likelihoodprocessing import sort_nicely
from bsoid_py.utils.visuals import *
def get_vidnames(folder):
"""
Gets a list of filenames within a folder
:param folder: str,... | 5,705 | 34.886792 | 109 | py |
B-SOID | B-SOID-master/bsoid_py/utils/visuals.py | """
Visualization functions and saving plots.
"""
import os
import time
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from matplotlib.axes._axes import _log as matplotlib_axes_logger
import numpy as np
import pandas as pd
import seaborn as sn
from bsoid_py.config import *
matplotlib_axes_l... | 8,980 | 43.02451 | 113 | py |
B-SOID | B-SOID-master/bsoid_umap/main.py | """
A master that runs BOTH
1. Training a unsupervised + supervised machine learning model based on patterns in spatio-temporal (x,y) changes.
2. Predicting new behaviors using (x,y) based on learned classifier.
"""
import os
import time
import itertools
import joblib
import numpy as np
import pandas as pd
from bsoi... | 10,285 | 55.828729 | 117 | py |
B-SOID | B-SOID-master/bsoid_umap/classify.py | """
Classify behaviors based on (x,y) using trained B-SOiD behavioral model.
B-SOiD behavioral model has been developed using bsoid_umap.main.build()
"""
import math
import itertools
import numpy as np
from bsoid_umap.utils import videoprocessing
from bsoid_umap.utils.likelihoodprocessing import boxcar_center
from b... | 6,827 | 43.337662 | 112 | py |
B-SOID | B-SOID-master/bsoid_umap/__init__.py | 0 | 0 | 0 | py | |
B-SOID | B-SOID-master/bsoid_umap/train.py | """
Based on the natural statistics of the mouse configuration using (x,y) positions,
we distill information down to 3 dimensions and run unsupervised pattern recognition.
Then, we utilize these output and original feature space to train a B-SOiD neural network model.
"""
import math
import itertools
import random
im... | 12,714 | 51.110656 | 121 | py |
B-SOID | B-SOID-master/bsoid_umap/config/GLOBAL_CONFIG.py | ################### THINGS YOU PROBABLY DONT'T WANT TO CHANGE ###################
import logging
import sys
logging.basicConfig(
format='%(asctime)s %(levelname)-8s %(message)s',
level='INFO',
datefmt='%Y-%m-%d %H:%M:%S',
stream=sys.stdout)
# UMAP params, nonlinear transform
UMAP_PARAMS = {
'n_co... | 1,176 | 29.179487 | 86 | py |
B-SOID | B-SOID-master/bsoid_umap/config/LOCAL_CONFIG.py | ################### THINGS YOU MAY WANT TO CHANGE ###################
BASE_PATH = '/Users/ahsu/B-SOID/datasets' # Base directory path.
TRAIN_FOLDERS = ['/Train1', '/Train2'] # Data folders used to training neural network.
PREDICT_FOLDERS = ['/Data1'] # Data folders, can contain the same as training or new data for ... | 1,411 | 51.296296 | 114 | py |
B-SOID | B-SOID-master/bsoid_umap/config/__init__.py | from bsoid_umap.config.LOCAL_CONFIG import *
from bsoid_umap.config.GLOBAL_CONFIG import * | 90 | 44.5 | 45 | py |
B-SOID | B-SOID-master/bsoid_umap/utils/likelihoodprocessing.py | """
likelihood processing utilities
Forward fill low likelihood (x,y)
"""
import glob
import re
import numpy as np
from tqdm import tqdm
from bsoid_umap.utils.visuals import *
def boxcar_center(a, n):
a1 = pd.Series(a)
moving_avg = np.array(a1.rolling(window=n, min_periods=1, center=True).mean())
retu... | 4,564 | 30.701389 | 108 | py |
B-SOID | B-SOID-master/bsoid_umap/utils/statistics.py | """
Summary statistics
"""
import os
import time
import numpy as np
import pandas as pd
from bsoid_umap.config import *
def feat_dist(feats):
feat_range = []
feat_med = []
p_cts = []
edges = []
for i in range(feats.shape[0]):
feat_range.append([np.quantile(feats[i, :], 0.05), np.quantil... | 4,859 | 35.541353 | 103 | py |
B-SOID | B-SOID-master/bsoid_umap/utils/videoprocessing.py | """
Extracting frames from videos
"""
import glob
import random
import numpy as np
import cv2
from tqdm import tqdm
from bsoid_umap.utils.likelihoodprocessing import sort_nicely
from bsoid_umap.utils.visuals import *
def get_vidnames(folder):
"""
Gets a list of filenames within a folder
:param folder: ... | 5,824 | 34.95679 | 109 | py |
B-SOID | B-SOID-master/bsoid_umap/utils/visuals.py | """
Visualization functions and saving plots.
"""
import os
import time
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from matplotlib.axes._axes import _log as matplotlib_axes_logger
import numpy as np
import pandas as pd
import seaborn as sn
from bsoid_umap.config import *
matplotlib_axes... | 8,376 | 44.037634 | 113 | py |
SFL-Structural-Federated-Learning | SFL-Structural-Federated-Learning-main/main.py | import torch
import random
import copy
import numpy as np
import time
from BResidual import BResidual
from options import arg_parameter
from data_util import load_cifar10, load_mnist
from federated import Cifar10FedEngine
from aggregator import parameter_aggregate, read_out
from util import *
def main(args):
args... | 5,188 | 37.437037 | 120 | py |
SFL-Structural-Federated-Learning | SFL-Structural-Federated-Learning-main/BResidual.py | import torch.nn as nn
import torch
from collections import namedtuple
import numpy as np
union = lambda *dicts: {k: v for d in dicts for (k, v) in d.items()}
sep = '_'
RelativePath = namedtuple('RelativePath', ('parts'))
rel_path = lambda *parts: RelativePath(parts)
class BResidual(nn.Module):
def __init__(self,... | 6,919 | 32.756098 | 171 | py |
SFL-Structural-Federated-Learning | SFL-Structural-Federated-Learning-main/GraphConstructor.py | import torch
import torch.nn as nn
import torch.nn.functional as F
class GraphConstructor(nn.Module):
def __init__(self, nnodes, k, dim, device, alpha=3, static_feat=None):
super(GraphConstructor, self).__init__()
self.nnodes = nnodes
if static_feat is not None:
xd = static_fea... | 2,074 | 31.421875 | 103 | py |
SFL-Structural-Federated-Learning | SFL-Structural-Federated-Learning-main/aggregator.py | import copy
import torch
import os
import pickle as pk
from util import sd_matrixing
from data_util import normalize_adj
from GraphConstructor import GraphConstructor
from optimiser import FedProx
import numpy as np
from scipy import linalg
def parameter_aggregate(args, A, w_server, global_model, server_state, client... | 6,429 | 34.921788 | 121 | py |
SFL-Structural-Federated-Learning | SFL-Structural-Federated-Learning-main/optimiser.py | import numpy as np
import torch
from collections import namedtuple
from util import PiecewiseLinear
from torch.optim.optimizer import Optimizer, required
import torch.distributed as dist
class TorchOptimiser():
def __init__(self, weights, optimizer, step_number=0, **opt_params):
self.weights = weights
... | 6,524 | 35.049724 | 97 | py |
SFL-Structural-Federated-Learning | SFL-Structural-Federated-Learning-main/data_util.py | import torch
import numpy as np
import scipy.sparse as sp
from torchvision import datasets
from collections import namedtuple
from torchvision import datasets, transforms
import pickle as pk
def load_image(args):
data_dir = "./data/" + str(args.dataset)
data_mean = (0.4914, 0.4822, 0.4465) # equals np.mean(t... | 11,858 | 36.647619 | 119 | py |
SFL-Structural-Federated-Learning | SFL-Structural-Federated-Learning-main/federated.py | import threading
import datetime
import torch
import time
import numpy as np
from BResidual import BResidual
from optimiser import SGD
from util import sd_matrixing, PiecewiseLinear, trainable_params, StatsLogger
class Cifar10FedEngine:
def __init__(self, args, dataloader, global_param, server_param, local_param,... | 5,404 | 35.033333 | 101 | py |
SFL-Structural-Federated-Learning | SFL-Structural-Federated-Learning-main/options.py | import argparse
def arg_parameter():
parser = argparse.ArgumentParser()
# Training arguments
parser.add_argument('--device', type=str, default='cuda:1', help='')
parser.add_argument('--dataset', type=str, default='mnist', help="name of dataset")
parser.add_argument('--adj_data', type=str, default=... | 6,621 | 70.204301 | 143 | py |
SFL-Structural-Federated-Learning | SFL-Structural-Federated-Learning-main/util.py | import datetime
import random
import os
import torch
import numpy as np
from collections import namedtuple
from functools import singledispatch
def print2file(buf, out_file, p=False):
if p:
print(buf)
outfd = open(out_file, 'a+')
outfd.write(str(datetime.datetime.now()) + '\t' + buf + '\n')
ou... | 2,561 | 24.366337 | 117 | py |
parameter-exchange | parameter-exchange-master/results_eval/scripts/divider.py | #!/usr/bin/env python3
"""Test module to develop divider scripts"""
import os
from typing import List, Union
# noinspection PyUnresolvedReferences
from plot.colors import (maroon, orange, yellow, green, purple, pink, blue,
lightblue, bar_colors)
# noinspection PyUnresolvedReferences
from plot... | 3,469 | 35.145833 | 79 | py |
parameter-exchange | parameter-exchange-master/results_eval/scripts/provider_comm.py | #!/usr/bin/env python3
"""Bloom Size Plot."""
import os
from plot.colors import bar_colors
from plot.plot import (bar_plot, OUTPUT_DIR, INPUT_DIR, stacked_bar_plot,
read_data, stacked_bar_plot_mult, convert_to_gb)
PLOT_ALL = 1
EXTENSION = '.png'
output_dir_provider = OUTPUT_DIR + "provider_com... | 10,408 | 38.729008 | 79 | py |
parameter-exchange | parameter-exchange-master/results_eval/scripts/provider_time.py | #!/usr/bin/env python3
"""Bloom Size Plot."""
import os
from typing import List, Union
# noinspection PyUnresolvedReferences
from plot.colors import bar_colors, maroon
# noinspection PyUnresolvedReferences
from plot.plot import (OUTPUT_DIR, INPUT_DIR,
read_data, stacked_bar_plot_mult, EXTENSION,... | 16,340 | 39.649254 | 79 | py |
parameter-exchange | parameter-exchange-master/results_eval/scripts/client_ram.py | #!/usr/bin/env python3
"""Bloom Size Plot."""
import os
from plot.plot import (OUTPUT_DIR, INPUT_DIR,
read_y_only, read_data, read_ram,
mean_confidence_interval, error_plot_mult, )
PLOT_ALL = 1
output_dir = OUTPUT_DIR + "client/"
os.makedirs(output_dir, exist_ok=True)
in... | 2,377 | 32.492958 | 85 | py |
parameter-exchange | parameter-exchange-master/results_eval/scripts/bloom_full_cap.py | #!/usr/bin/env python3
"""Bloom dependence on Capacity."""
from typing import List
import numpy as np
from numpy import log as ln
# noinspection PyUnresolvedReferences
from plot.plot import (read_data, convert_to_gb, convert_to_minutes,
INPUT_DIR, OUTPUT_DIR, error_plot_mult,
... | 3,809 | 28.083969 | 79 | py |
parameter-exchange | parameter-exchange-master/results_eval/scripts/psi_comm.py | #!/usr/bin/env python3
"""Bloom Size Plot."""
import math
import os
from plot.plot import (read_data, INPUT_DIR, OUTPUT_DIR,
read_data_mult, convert_to_gb, stacked_bar_plot,
stacked_bar_plot_mult)
PLOT_ALL = True
output_dir = OUTPUT_DIR + 'psi_comm/'
os.makedirs(output_di... | 5,945 | 32.784091 | 79 | py |
parameter-exchange | parameter-exchange-master/results_eval/scripts/psi_time.py | #!/usr/bin/env python3
"""Bloom Size Plot."""
import os
# noinspection PyUnresolvedReferences
from plot.colors import green, orange, blue
from plot.plot import (read_data, INPUT_DIR, OUTPUT_DIR,
read_data_mult, error_plot_mult, convert_to_minutes,
EXTENSION, plot_settings,... | 9,773 | 33.415493 | 82 | py |
parameter-exchange | parameter-exchange-master/results_eval/scripts/all.py | #!/usr/bin/env python3
"""Execute all plot scripts."""
# import client_ram
# noinspection PyUnresolvedReferences
import bloom_full_cap
# noinspection PyUnresolvedReferences
import bloom_full_err
# noinspection PyUnresolvedReferences
import bloom_full_query
# noinspection PyUnresolvedReferences
import client_time
# noi... | 555 | 24.272727 | 37 | py |
parameter-exchange | parameter-exchange-master/results_eval/scripts/client_comm.py | #!/usr/bin/env python3
"""Bloom Size Plot."""
import copy
import os
from plot.colors import *
from plot.plot import (bar_plot, OUTPUT_DIR, INPUT_DIR, stacked_bar_plot,
read_data, join_stack_data, bar_plot_mult,
stacked_bar_plot_two_y,
convert_to_gb,... | 10,321 | 39.960317 | 79 | py |
parameter-exchange | parameter-exchange-master/results_eval/scripts/bloom_full_query.py | #!/usr/bin/env python3
"""Bloom dependence on Query Size."""
# noinspection PyUnresolvedReferences
from typing import List
from plot.plot import (read_data, convert_to_gb, convert_to_minutes,
INPUT_DIR, OUTPUT_DIR, error_plot_mult,
EXTENSION, plot_settings, Legend)
PLOT_... | 1,381 | 28.404255 | 74 | py |
parameter-exchange | parameter-exchange-master/results_eval/scripts/client_time.py | #!/usr/bin/env python3
"""Bloom Size Plot."""
import copy
import os
from typing import List, Union
from matplotlib import patches
# noinspection PyUnresolvedReferences
from plot.colors import (maroon, orange, yellow, green, purple, pink, blue,
lightblue)
# noinspection PyUnresolvedReferences
... | 33,636 | 41.959132 | 80 | py |
parameter-exchange | parameter-exchange-master/results_eval/scripts/ot_time.py | #!/usr/bin/env python3
"""Bloom Size Plot."""
import os
# noinspection PyUnresolvedReferences
from plot.colors import blue, orange, green
from plot.plot import (read_data, INPUT_DIR, OUTPUT_DIR,
error_plot_mult, read_data_mult, convert_to_minutes,
EXTENSION, plot_settings,... | 11,744 | 34.917431 | 81 | py |
parameter-exchange | parameter-exchange-master/results_eval/scripts/bloom_full_err.py | #!/usr/bin/env python3
"""Bloom dependence on Error Rate."""
import numpy as np
from numpy import log as ln
# noinspection PyUnresolvedReferences
from plot.plot import (read_data, convert_to_gb, convert_to_minutes,
INPUT_DIR, OUTPUT_DIR, read_fp,
error_plot_mult, EXTENSIO... | 4,716 | 28.666667 | 78 | py |
parameter-exchange | parameter-exchange-master/results_eval/scripts/provider_ram.py | #!/usr/bin/env python3
"""Ram Plot of Provider Eval."""
from plot.plot import (OUTPUT_DIR, INPUT_DIR,
read_y_only, read_ram,
mean_confidence_interval, error_plot_mult)
PLOT_ALL = True
output_dir = OUTPUT_DIR + "provider/"
input_dir = INPUT_DIR + "provider/"
# Offset 2----... | 1,975 | 34.285714 | 86 | py |
parameter-exchange | parameter-exchange-master/results_eval/scripts/__init__.py | #!/usr/bin/env python3
"Plot Module"
| 37 | 11.666667 | 22 | py |
parameter-exchange | parameter-exchange-master/results_eval/scripts/ot_comm.py | #!/usr/bin/env python3
"""Bloom Size Plot."""
import math
import os
from plot.plot import (read_data, INPUT_DIR, OUTPUT_DIR,
read_data_mult, stacked_bar_plot, convert_to_gb,
stacked_bar_plot_mult)
PLOT_ALL = True
output_dir = OUTPUT_DIR + 'ot_comm/'
os.makedirs(output_dir... | 6,924 | 31.97619 | 82 | py |
parameter-exchange | parameter-exchange-master/results_eval/scripts/bloom_full_insert.py | #!/usr/bin/env python3
"""Bloom dependence on Insert Size."""
# noinspection PyUnresolvedReferences
from typing import List
from plot.plot import (read_data, convert_to_gb, convert_to_minutes,
INPUT_DIR, OUTPUT_DIR, error_plot_mult,
EXTENSION, plot_settings, Legend)
PLOT... | 1,310 | 27.5 | 70 | py |
parameter-exchange | parameter-exchange-master/results_eval/scripts/metric.py | #!/usr/bin/env python3
"""Bloom Size Plot."""
import os
# noinspection PyUnresolvedReferences
import pickle
from plot.plot import (error_plot_mult, read_data,
INPUT_DIR, OUTPUT_DIR, EXTENSION, plot_settings)
PLOT_ALL = True
output_dir = OUTPUT_DIR + 'metric/'
os.makedirs(output_dir, exist_ok=Tr... | 7,586 | 29.716599 | 79 | py |
parameter-exchange | parameter-exchange-master/results_eval/scripts/plot/plot.py | #!/usr/bin/env python3
"""
This file contains general plot functionality.
"""
import json
import math
import os
from contextlib import contextmanager
from copy import deepcopy
from typing import List, Tuple, Dict, Union
import matplotlib.pyplot as plt
import numpy as np
import scipy.stats
from matplotlib import patche... | 51,086 | 32.543664 | 87 | py |
parameter-exchange | parameter-exchange-master/results_eval/scripts/plot/__init__.py | 0 | 0 | 0 | py | |
parameter-exchange | parameter-exchange-master/results_eval/scripts/plot/tls.py | #!/usr/bin/env python3
"""This module contains functions for the theoretic TLS approximation."""
from copy import deepcopy
# Deprecated ------------------------------------------------------------------
# Handshake cost < 1s
# https://www.comsys.rwth-aachen.de/fileadmin/papers/2019/2019-hiller-lcn
# -case_for_tls_sess... | 1,332 | 35.027027 | 79 | py |
parameter-exchange | parameter-exchange-master/results_eval/scripts/plot/colors.py | "This module contains the different colors for the plots."
# Matplotlib Default colors
blue = '#377eb8'
orange = '#ff7f00'
green = '#4daf4a'
red = '#e41a1c'
purple = '#984ea3'
brown = '#a65628'
pink = '#f781bf'
gray = '#999999'
yellow = 'gold'
lightblue = '#92c5de'
lightgreen = '#bae4b3'
lightorange = '#fed98e'
darkor... | 459 | 20.904762 | 58 | py |
parameter-exchange | parameter-exchange-master/src/setup.py | #!/usr/bin/env python3
"""Setup requirements.
Copyright (c) 2020.
Author: Erik Buchholz
Maintainer: Erik Buchholz
E-mail: [email protected]
"""
from setuptools import setup, find_packages
from lib import config
with open(config.WORKING_DIR + "README.md", "r") as f:
readme = f.read()
with open(config... | 852 | 25.65625 | 68 | py |
parameter-exchange | parameter-exchange-master/src/client_db_cli.py | #!/usr/bin/env python3
"""This monument contains the CLI to interact with the client DB.
Copyright (c) 2020.
Author: Erik Buchholz
Maintainer: Erik Buchholz
E-mail: [email protected]
"""
import logging
import sys
from lib import db_cli, config
from lib.base_client import UserType
from lib.logging import ... | 538 | 25.95 | 72 | py |
parameter-exchange | parameter-exchange-master/src/PSIReceiver.py | #!/usr/bin/env python3
"""Acts as receiver for PSIs.
Copyright (c) 2020.
Author: Erik Buchholz
Maintainer: Erik Buchholz
E-mail: [email protected]
"""
import argparse
import datetime
import logging
import sys
from typing import List
import lib.config as config
from lib.logging import configure_root_loger... | 2,277 | 29.783784 | 77 | py |
parameter-exchange | parameter-exchange-master/src/OTReceiver.py | #!/usr/bin/env python3
"""Acts as receiver for OTs.
Copyright (c) 2020.
Author: Erik Buchholz
Maintainer: Erik Buchholz
E-mail: [email protected]
"""
import argparse
import datetime
import logging
import sys
from typing import List
import lib.config as config
from lib.logging import configure_root_loger
... | 2,157 | 29.394366 | 77 | py |
parameter-exchange | parameter-exchange-master/src/client.py | #!/usr/bin/env python3
"""Client Application of client type end-users.
Copyright (c) 2020.
Author: Erik Buchholz
Maintainer: Erik Buchholz
E-mail: [email protected]
"""
import argparse
import atexit
import copy
import json
import logging
import multiprocessing
import pickle
import pprint
import shutil
imp... | 19,715 | 38.432 | 87 | py |
parameter-exchange | parameter-exchange-master/src/random_record_generator.py | #!/usr/bin/env python3
"""Generate random records.
Copyright (c) 2020.
Author: Erik Buchholz
Maintainer: Erik Buchholz
E-mail: [email protected]
"""
import argparse
import sys
from typing import List
from lib import config
import random
def main(args=List[str]):
"""
Generate random records acco... | 1,483 | 28.098039 | 81 | py |
parameter-exchange | parameter-exchange-master/src/owner_db_cli.py | #!/usr/bin/env python3
"""This monument contains the CLI to interact with the owner DB.
Copyright (c) 2020.
Author: Erik Buchholz
Maintainer: Erik Buchholz
E-mail: [email protected]
"""
import logging
import sys
from lib import db_cli, config
from lib.base_client import UserType
from lib.logging import c... | 535 | 25.8 | 71 | py |
parameter-exchange | parameter-exchange-master/src/__init__.py | 0 | 0 | 0 | py | |
parameter-exchange | parameter-exchange-master/src/data_provider.py | #!/usr/bin/env python3
"""Client Application of data provider type end-users.
Copyright (c) 2020.
Author: Erik Buchholz
Maintainer: Erik Buchholz
E-mail: [email protected]
"""
import argparse
import json
import logging
import os
import pickle
import sys
import time
from typing import List, Tuple, Iterable... | 9,526 | 34.815789 | 80 | py |
parameter-exchange | parameter-exchange-master/src/tools/wzl_parser.py | #!/usr/bin/env python3
"""Parser for WZL Data.
Copyright (c) 2020.
Author: Erik Buchholz
Maintainer: Erik Buchholz
E-mail: [email protected]
"""
import json
from lib.config import WORKING_DIR
# Mappings from Names to Ints--------------------------------------------------
steuerung = {
'Siemens': 1
}... | 1,663 | 25.83871 | 79 | py |
parameter-exchange | parameter-exchange-master/src/tools/__init__.py | #!/usr/bin/env python3
"""This module..."""
| 44 | 14 | 22 | py |
parameter-exchange | parameter-exchange-master/src/tools/ikv_parser.py | #!/usr/bin/env python3
"""Parser for IKV Lego Data.
Copyright (c) 2020.
Author: Erik Buchholz
Maintainer: Erik Buchholz
E-mail: [email protected]
"""
import json
from lib.config import WORKING_DIR
with open(f"{WORKING_DIR}/data/ikv_data_unconverted.json", "r") as f:
d = json.load(f)
result = {}
list... | 1,429 | 27.039216 | 69 | py |
parameter-exchange | parameter-exchange-master/src/eval/bloom_eval.py | #!/usr/bin/env python3
"""Evaluate bloom filter properties.
Copyright (c) 2020.
Author: Erik Buchholz
Maintainer: Erik Buchholz
E-mail: [email protected]
"""
import argparse
import logging
import math
import os
import random
import time
from tempfile import NamedTemporaryFile
import numpy
from pybloomfil... | 8,821 | 38.738739 | 79 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.