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 |
|---|---|---|---|---|---|---|
time-series-forecasting-release | time-series-forecasting-release/preprocess_scripts/CIF_2016/non_moving_window/without_stl_decomposition/create_o12_tfrecords.py | from tfrecords_handler.non_moving_window.tfrecord_writer import TFRecordWriter
import os
output_path = "../../../../datasets/binary_data/CIF_2016/non_moving_window/without_stl_decomposition/"
if not os.path.exists(output_path):
os.makedirs(output_path)
if __name__ == '__main__':
tfrecord_writer = TFRecordWrit... | 1,143 | 51 | 125 | py |
time-series-forecasting-release | time-series-forecasting-release/preprocess_scripts/CIF_2016/non_moving_window/without_stl_decomposition/create_o6_tfrecords.py | from tfrecords_handler.non_moving_window.tfrecord_writer import TFRecordWriter
import os
output_path = "../../../../datasets/binary_data/CIF_2016/non_moving_window/without_stl_decomposition/"
if not os.path.exists(output_path):
os.makedirs(output_path)
if __name__ == '__main__':
tfrecord_writer = TFRecordWrit... | 1,148 | 51.227273 | 126 | py |
time-series-forecasting-release | time-series-forecasting-release/preprocess_scripts/NN5/moving_window/create_tfrecords.py | from tfrecords_handler.moving_window.tfrecord_writer import TFRecordWriter
import os
output_path = "../../../datasets/binary_data/NN5/moving_window/"
if not os.path.exists(output_path):
os.makedirs(output_path)
if __name__ == '__main__':
tfrecord_writer = TFRecordWriter(
input_size = 9,
output... | 1,051 | 44.73913 | 95 | py |
time-series-forecasting-release | time-series-forecasting-release/preprocess_scripts/NN5/moving_window/without_stl_decomposition/create_tfrecords.py | from tfrecords_handler.moving_window.tfrecord_writer import TFRecordWriter
import os
output_path = "../../../../datasets/binary_data/NN5/moving_window/without_stl_decomposition/"
if not os.path.exists(output_path):
os.makedirs(output_path)
if __name__ == '__main__':
tfrecord_writer = TFRecordWriter(
i... | 1,151 | 49.086957 | 120 | py |
time-series-forecasting-release | time-series-forecasting-release/preprocess_scripts/NN5/non_moving_window/create_tfrecords.py | from tfrecords_handler.non_moving_window.tfrecord_writer import TFRecordWriter
import os
output_path = "../../../datasets/binary_data/NN5/non_moving_window/"
if not os.path.exists(output_path):
os.makedirs(output_path)
if __name__ == '__main__':
tfrecord_writer = TFRecordWriter(
output_size = 56,
... | 1,035 | 46.090909 | 97 | py |
time-series-forecasting-release | time-series-forecasting-release/preprocess_scripts/NN5/non_moving_window/without_stl_decomposition/create_tfrecords.py | from tfrecords_handler.non_moving_window.tfrecord_writer import TFRecordWriter
import os
output_path = "../../../../datasets/binary_data/NN5/non_moving_window/without_stl_decomposition/"
if not os.path.exists(output_path):
os.makedirs(output_path)
if __name__ == '__main__':
tfrecord_writer = TFRecordWriter(
... | 1,135 | 50.636364 | 122 | py |
time-series-forecasting-release | time-series-forecasting-release/preprocess_scripts/kaggle_web_traffic/moving_window/create_tfrecords.py | from tfrecords_handler.moving_window.tfrecord_writer import TFRecordWriter
import os
output_path = "../../../datasets/binary_data/kaggle_web_traffic/moving_window/"
if not os.path.exists(output_path):
os.makedirs(output_path)
if __name__ == '__main__':
tfrecord_writer = TFRecordWriter(
input_size ... | 1,996 | 50.205128 | 113 | py |
time-series-forecasting-release | time-series-forecasting-release/preprocess_scripts/kaggle_web_traffic/moving_window/without_stl_decomposition/create_tfrecords.py | from tfrecords_handler.moving_window.tfrecord_writer import TFRecordWriter
import os
output_path = "../../../../datasets/binary_data/kaggle_web_traffic/moving_window/without_stl_decomposition/"
if not os.path.exists(output_path):
os.makedirs(output_path)
if __name__ == '__main__':
tfrecord_writer = TFRecordWr... | 2,163 | 54.487179 | 138 | py |
time-series-forecasting-release | time-series-forecasting-release/preprocess_scripts/kaggle_web_traffic/non_moving_window/create_tfrecords.py | from tfrecords_handler.non_moving_window.tfrecord_writer import TFRecordWriter
import os
output_path = "../../../datasets/binary_data/kaggle_web_traffic/non_moving_window/"
if not os.path.exists(output_path):
os.makedirs(output_path)
if __name__ == '__main__':
tfrecord_writer = TFRecordWriter(
output_... | 1,113 | 49.636364 | 115 | py |
time-series-forecasting-release | time-series-forecasting-release/preprocess_scripts/kaggle_web_traffic/non_moving_window/without_stl_decomposition/create_tfrecords.py | from tfrecords_handler.non_moving_window.tfrecord_writer import TFRecordWriter
import os
output_path = "../../../../datasets/binary_data/kaggle_web_traffic/non_moving_window/without_stl_decomposition/"
if not os.path.exists(output_path):
os.makedirs(output_path)
if __name__ == '__main__':
tfrecord_writer ... | 1,217 | 54.363636 | 140 | py |
time-series-forecasting-release | time-series-forecasting-release/preprocess_scripts/M4/moving_window/create_tfrecords.py | from tfrecords_handler.moving_window.tfrecord_writer import TFRecordWriter
import os
output_path = "../../../datasets/binary_data/M4/moving_window/"
if not os.path.exists(output_path):
os.makedirs(output_path)
if __name__ == '__main__':
# macro data
tfrecord_writer = TFRecordWriter(
input_size = 1... | 5,637 | 50.724771 | 109 | py |
time-series-forecasting-release | time-series-forecasting-release/preprocess_scripts/M4/moving_window/without_stl_decomposition/create_tfrecords.py | from tfrecords_handler.moving_window.tfrecord_writer import TFRecordWriter
import os
output_path = "'../../../../datasets/binary_data/M4/moving_window/without_stl_decomposition/"
if not os.path.exists(output_path):
os.makedirs(output_path)
if __name__ == '__main__':
# macro data
tfrecord_writer = TFRecord... | 6,093 | 54.908257 | 134 | py |
time-series-forecasting-release | time-series-forecasting-release/preprocess_scripts/M4/non_moving_window/create_tfrecords.py | from tfrecords_handler.non_moving_window.tfrecord_writer import TFRecordWriter
import os
output_path = "../../../datasets/binary_data/M4/non_moving_window/"
if not os.path.exists(output_path):
os.makedirs(output_path)
if __name__ == '__main__':
# macro data
tfrecord_writer = TFRecordWriter(
output... | 5,476 | 52.174757 | 110 | py |
time-series-forecasting-release | time-series-forecasting-release/preprocess_scripts/M4/non_moving_window/without_stl_decomposition/create_tfrecords.py | from tfrecords_handler.non_moving_window.tfrecord_writer import TFRecordWriter
import os
output_path = "../../../../datasets/binary_data/M4/non_moving_window/without_stl_decomposition/"
if not os.path.exists(output_path):
os.makedirs(output_path)
if __name__ == '__main__':
# macro data
tfrecord_writer = T... | 5,932 | 56.601942 | 135 | py |
time-series-forecasting-release | time-series-forecasting-release/preprocess_scripts/Tourism/moving_window/create_tfrecords.py | from tfrecords_handler.moving_window.tfrecord_writer import TFRecordWriter
import os
output_path = "../../../datasets/binary_data/Tourism/moving_window/"
if not os.path.exists(output_path):
os.makedirs(output_path)
if __name__ == '__main__':
tfrecord_writer = TFRecordWriter(
input_size = 15,
o... | 1,098 | 46.782609 | 104 | py |
time-series-forecasting-release | time-series-forecasting-release/preprocess_scripts/Tourism/moving_window/without_stl_decomposition/create_tfrecords.py | from tfrecords_handler.moving_window.tfrecord_writer import TFRecordWriter
import os
output_path = "../../../../datasets/binary_data/Tourism/moving_window/without_stl_decomposition/"
if not os.path.exists(output_path):
os.makedirs(output_path)
if __name__ == '__main__':
tfrecord_writer = TFRecordWriter(
... | 1,198 | 51.130435 | 129 | py |
time-series-forecasting-release | time-series-forecasting-release/preprocess_scripts/Tourism/non_moving_window/create_tfrecords.py | from tfrecords_handler.non_moving_window.tfrecord_writer import TFRecordWriter
import os
output_path = "../../../datasets/binary_data/Tourism/non_moving_window/"
if not os.path.exists(output_path):
os.makedirs(output_path)
if __name__ == '__main__':
tfrecord_writer = TFRecordWriter(
output_size = 24,
... | 1,063 | 47.363636 | 103 | py |
time-series-forecasting-release | time-series-forecasting-release/preprocess_scripts/Tourism/non_moving_window/without_stl_decomposition/create_tfrecords.py | from tfrecords_handler.non_moving_window.tfrecord_writer import TFRecordWriter
import os
output_path = "../../../../datasets/binary_data/Tourism/non_moving_window/without_stl_decomposition/"
if not os.path.exists(output_path):
os.makedirs(output_path)
if __name__ == '__main__':
tfrecord_writer = TFRecordWrite... | 1,163 | 51.909091 | 128 | py |
time-series-forecasting-release | time-series-forecasting-release/preprocess_scripts/M3/train_test_data_splitter.py | import csv
data_file = "../../datasets/text_data/M3/M3C.csv"
train_data_file = "../../datasets/text_data/M3/Train_Dataset.csv"
results_file = "../../datasets/text_data/M3/Test_Dataset.csv"
with open(data_file, "r") as original_file, open(train_data_file, "w") as train_out, open(results_file, "w") as results_out:
... | 986 | 35.555556 | 124 | py |
time-series-forecasting-release | time-series-forecasting-release/preprocess_scripts/M3/moving_window/create_tfrecords.py | from tfrecords_handler.moving_window.tfrecord_writer import TFRecordWriter
import os
output_path = "../../../datasets/binary_data/M3/moving_window/"
if not os.path.exists(output_path):
os.makedirs(output_path)
if __name__ == '__main__':
# macro data
tfrecord_writer = TFRecordWriter(
input_size = 1... | 5,644 | 50.788991 | 109 | py |
time-series-forecasting-release | time-series-forecasting-release/preprocess_scripts/M3/moving_window/without_stl_decomposition/create_tfrecords.py | from tfrecords_handler.moving_window.tfrecord_writer import TFRecordWriter
import os
output_path = "../../../../datasets/binary_data/M3/moving_window/without_stl_decomposition/"
if not os.path.exists(output_path):
os.makedirs(output_path)
if __name__ == '__main__':
# macro data
tfrecord_writer = TFRecordW... | 6,099 | 54.963303 | 134 | py |
time-series-forecasting-release | time-series-forecasting-release/preprocess_scripts/M3/non_moving_window/create_tfrecords.py | from tfrecords_handler.non_moving_window.tfrecord_writer import TFRecordWriter
import os
output_path = "../../../datasets/binary_data/M3/non_moving_window/"
if not os.path.exists(output_path):
os.makedirs(output_path)
if __name__ == '__main__':
# macro data
tfrecord_writer = TFRecordWriter(
output... | 5,477 | 52.184466 | 110 | py |
time-series-forecasting-release | time-series-forecasting-release/preprocess_scripts/M3/non_moving_window/without_stl_decomposition/create_tfrecords.py | from tfrecords_handler.non_moving_window.tfrecord_writer import TFRecordWriter
import os
output_path = "../../../../datasets/binary_data/M3/non_moving_window/without_stl_decomposition/"
if not os.path.exists(output_path):
os.makedirs(output_path)
if __name__ == '__main__':
# macro data
tfrecord_writer = T... | 5,931 | 56.592233 | 135 | py |
time-series-forecasting-release | time-series-forecasting-release/graph_plotter/training_curve_plotter.py | import tensorflow as tf
import numpy as np
class CurvePlotter:
def __init__(self, session, no_of_curves):
self.__session = session
self.__writer_train = tf.summary.FileWriter('./logs/plot_train')
if no_of_curves == 2:
self.__writer_val = tf.summary.FileWriter('./logs/plot_val')... | 906 | 38.434783 | 96 | py |
time-series-forecasting-release | time-series-forecasting-release/configs/global_configs.py | # configs for the model training
class model_training_configs:
VALIDATION_ERRORS_DIRECTORY = 'results/validation_errors/'
INFO_FREQ = 1
# configs for the model testing
class model_testing_configs:
RNN_FORECASTS_DIRECTORY = 'results/rnn_forecasts/'
RNN_ERRORS_DIRECTORY = 'results/errors'
PROCESSED_R... | 544 | 29.277778 | 75 | py |
time-series-forecasting-release | time-series-forecasting-release/tfrecords_handler/moving_window/tfrecord_writer.py | import tensorflow as tf
import numpy as np
import pandas as pd
class TFRecordWriter:
def __init__(self, **kwargs):
self.__input_size = kwargs['input_size']
self.__output_size = kwargs['output_size']
self.__train_file_path = kwargs['train_file_path']
self.__validate_file_path = kwar... | 8,497 | 50.817073 | 148 | py |
time-series-forecasting-release | time-series-forecasting-release/tfrecords_handler/moving_window/tfrecord_reader.py | import tensorflow as tf
class TFRecordReader:
def __init__(self, input_size, output_size, metadata_size):
self.__input_size = input_size
self.__output_size = output_size
self.__metadata_size = metadata_size
def train_data_parser(self, serialized_example):
context_parsed, seque... | 2,277 | 41.981132 | 119 | py |
time-series-forecasting-release | time-series-forecasting-release/tfrecords_handler/non_moving_window/tfrecord_writer.py | import tensorflow as tf
import numpy as np
import pandas as pd
import csv
class TFRecordWriter:
def __init__(self, **kwargs):
self.__output_size = kwargs['output_size']
self.__train_file_path = kwargs['train_file_path']
self.__validate_file_path = kwargs['validate_file_path']
self... | 7,776 | 50.164474 | 124 | py |
time-series-forecasting-release | time-series-forecasting-release/tfrecords_handler/non_moving_window/tfrecord_reader.py | import tensorflow as tf
class TFRecordReader:
def train_data_parser(self, serialized_example):
context_parsed, sequence_parsed = tf.parse_single_sequence_example(
serialized_example,
context_features=({
"sequence_length": tf.FixedLenFeature([], dtype=tf.int64)
... | 1,967 | 40 | 119 | py |
time-series-forecasting-release | time-series-forecasting-release/utility_scripts/persist_optimized_config_results.py | def persist_results(results, file):
file_object = open(file, mode = 'w')
for k, v in results.items():
file_object.write(str(k) + ' >>> ' + str(v) + '\n\n')
file_object.close()
| 198 | 23.875 | 61 | py |
time-series-forecasting-release | time-series-forecasting-release/utility_scripts/time_series_length_calculator.py | import argparse
import csv
argument_parser = argparse.ArgumentParser("Calculate the time series length")
argument_parser.add_argument('--data_file', required=True, help='The full name of the data file')
argument_parser.add_argument('--output_file', required=True, help='The full name of the output file')
args = argume... | 652 | 30.095238 | 101 | py |
time-series-forecasting-release | time-series-forecasting-release/utility_scripts/invoke_r_final_evaluation.py | import subprocess
from configs.global_configs import model_testing_configs
def invoke_r_script(args, moving_window):
if moving_window:
subprocess.call(["Rscript", "--vanilla", "error_calculator/moving_window/final_evaluation.R", args[0], model_testing_configs.RNN_ERRORS_DIRECTORY, model_testing_configs.PRO... | 772 | 84.888889 | 313 | py |
time-series-forecasting-release | time-series-forecasting-release/utility_scripts/hyperparameter_scripts/hyperparameter_summary_generator.py | ## This file concatenates the optimal hyperparameter configs across all the models for the same dataset and writes to a csv file
import glob
import argparse
import pandas as pd
import re
from utility_scripts.hyperparameter_scripts.hyperparameter_config_reader import read_optimal_hyperparameter_values
# get the differ... | 2,639 | 46.142857 | 128 | py |
time-series-forecasting-release | time-series-forecasting-release/utility_scripts/hyperparameter_scripts/hyperparameter_config_reader.py | import re
def read_optimal_hyperparameter_values(file_name):
# define dictionary to store the hyperparameter values
hyperparameter_values_dic = {}
with open(file_name) as configs_file:
configs = configs_file.readlines()
for config in configs:
if not config.startswith('#') and c... | 1,169 | 36.741935 | 91 | py |
time-series-forecasting-release | time-series-forecasting-release/utility_scripts/error_summary_scripts/error_summary_generator.py | ## This file concatenates the results across all the models for the same dataset and writes the mean SMAPE, median SMAPE, ranked SMAPE,
# mean MASE, median MASE and ranked MASE across the time series to a csv file
import glob
import argparse
import pandas as pd
import re
import numpy as np
from collections import defa... | 3,726 | 38.648936 | 135 | py |
time-series-forecasting-release | time-series-forecasting-release/utility_scripts/error_summary_scripts/ensembling_forecasts.py | ## This file concatenates the results across all the models for the same dataset, takes the median of errors for different seeds and writes the mean SMAPE, median SMAPE, ranked SMAPE,
# mean MASE, median MASE and ranked MASE to a csv file
import glob
import argparse
import pandas as pd
import numpy as np
from collecti... | 1,864 | 34.865385 | 183 | py |
time-series-forecasting-release | time-series-forecasting-release/utility_scripts/error_summary_scripts/clusters_results_merger.py | ## This file concatenates the error results of the different clusters for a given dataset
## The script requires that all the files(mean_median file, all_smape_errors and all_mase_errors files) are present for all the clusters subject to consideration
import glob
import numpy as np
import argparse
import re
from colle... | 4,761 | 38.032787 | 161 | py |
time-series-forecasting-release | time-series-forecasting-release/rnn_architectures/seq2seq_model/with_decoder/non_moving_window/unaccumulated_error/seq2seq_model_trainer.py | import numpy as np
import tensorflow as tf
from tensorflow.python.layers.core import Dense
from tfrecords_handler.non_moving_window.tfrecord_reader import TFRecordReader
from configs.global_configs import model_training_configs
from configs.global_configs import training_data_configs
from configs.global_configs import ... | 16,182 | 54.611684 | 162 | py |
time-series-forecasting-release | time-series-forecasting-release/rnn_architectures/seq2seq_model/with_decoder/non_moving_window/unaccumulated_error/seq2seq_model_tester.py | import numpy as np
import tensorflow as tf
from tensorflow.python.layers.core import Dense
from tfrecords_handler.non_moving_window.tfrecord_reader import TFRecordReader
from configs.global_configs import training_data_configs
from configs.global_configs import gpu_configs
class Seq2SeqModelTester:
def __init__(s... | 12,870 | 53.538136 | 146 | py |
time-series-forecasting-release | time-series-forecasting-release/rnn_architectures/seq2seq_model/with_dense_layer/moving_window/unaccumulated_error/seq2seq_model_trainer.py | import numpy as np
import tensorflow as tf
from tfrecords_handler.moving_window.tfrecord_reader import TFRecordReader
from configs.global_configs import model_training_configs
from configs.global_configs import training_data_configs
from configs.global_configs import gpu_configs
class Seq2SeqModelTrainerWithDenseLaye... | 15,412 | 52.703833 | 135 | py |
time-series-forecasting-release | time-series-forecasting-release/rnn_architectures/seq2seq_model/with_dense_layer/moving_window/unaccumulated_error/seq2seq_model_tester.py | import numpy as np
import tensorflow as tf
from tfrecords_handler.moving_window.tfrecord_reader import TFRecordReader
from configs.global_configs import training_data_configs
from configs.global_configs import gpu_configs
class Seq2SeqModelTesterWithDenseLayer:
def __init__(self, **kwargs):
self.__use_bia... | 11,874 | 51.083333 | 170 | py |
time-series-forecasting-release | time-series-forecasting-release/rnn_architectures/seq2seq_model/with_dense_layer/non_moving_window/unaccumulated_error/seq2seq_model_trainer.py | import numpy as np
import tensorflow as tf
from tfrecords_handler.non_moving_window.tfrecord_reader import TFRecordReader
from configs.global_configs import model_training_configs
from configs.global_configs import training_data_configs
from configs.global_configs import gpu_configs
class Seq2SeqModelTrainerWithDenseL... | 14,802 | 53.223443 | 146 | py |
time-series-forecasting-release | time-series-forecasting-release/rnn_architectures/seq2seq_model/with_dense_layer/non_moving_window/unaccumulated_error/seq2seq_model_tester.py | import numpy as np
import tensorflow as tf
from tfrecords_handler.non_moving_window.tfrecord_reader import TFRecordReader
from configs.global_configs import training_data_configs
from configs.global_configs import gpu_configs
class Seq2SeqModelTesterWithDenseLayer:
def __init__(self, **kwargs):
self.__use... | 11,488 | 50.986425 | 146 | py |
time-series-forecasting-release | time-series-forecasting-release/rnn_architectures/stacking_model/stacking_model_tester.py | import numpy as np
import tensorflow as tf
from tfrecords_handler.moving_window.tfrecord_reader import TFRecordReader
from configs.global_configs import training_data_configs
from configs.global_configs import gpu_configs
class StackingModelTester:
def __init__(self, **kwargs):
self.__use_bias = kwargs["... | 10,712 | 49.533019 | 129 | py |
time-series-forecasting-release | time-series-forecasting-release/rnn_architectures/stacking_model/stacking_model_trainer.py | import numpy as np
import tensorflow as tf
from tfrecords_handler.moving_window.tfrecord_reader import TFRecordReader
from configs.global_configs import model_training_configs
from configs.global_configs import training_data_configs
from configs.global_configs import gpu_configs
class StackingModelTrainer:
def __... | 14,326 | 51.479853 | 136 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/Image_denoising_figure2/Noisier2Noise/models/unet_fastMRI.py | """
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
import torch
import math
from torch import nn
from torch.nn import functional as F
class unet_fastMRI(nn.Module):
"""
PyTorch imple... | 7,138 | 34.517413 | 131 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/Image_denoising_figure2/Noisier2Noise/models/__init__.py | from .unet_fastMRI import *
| 29 | 9 | 27 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/Image_denoising_figure2/Noisier2Noise/utils/progress_bar.py | from collections import OrderedDict
from numbers import Number
from tqdm import tqdm
from .meters import AverageMeter, RunningAverageMeter, TimeMeter
class ProgressBar:
def __init__(self, iterable, epoch=None, prefix=None, quiet=False):
self.epoch = epoch
self.quiet = quiet
self.prefix = p... | 1,789 | 37.913043 | 115 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/Image_denoising_figure2/Noisier2Noise/utils/utils_image.py | import os
import math
import random
import numpy as np
import torch
import cv2
from torchvision.utils import make_grid
def modcrop(img, scale):
# img_in: BCHW or CHW or HW
#img = np.copy(img_in)
if img.ndim == 2:
H, W = img.shape
H_r, W_r = H % scale, W % scale
img = img[:H - H_r, ... | 10,256 | 37.852273 | 99 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/Image_denoising_figure2/Noisier2Noise/utils/train_utils.py | import argparse
import os
import logging
import numpy as np
import random
import sys
import torch
from datetime import datetime
from torch.serialization import default_restore_location
def add_logging_arguments(parser):
parser.add_argument("--seed", default=0, type=int, help="random number generator seed")
p... | 7,573 | 52.716312 | 138 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/Image_denoising_figure2/Noisier2Noise/utils/main_function_helpers.py | import torch
import argparse
import os
import yaml
import pathlib
import pickle
import logging
import sys
import time
from torch.utils.tensorboard import SummaryWriter
import torch.nn.functional as F
import torchvision
import glob
from torch.serialization import default_restore_location
from torch.utils.data import Dat... | 22,955 | 45.563895 | 182 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/Image_denoising_figure2/Noisier2Noise/utils/util_calculate_psnr_ssim.py | import cv2
import numpy as np
import torch
# from https://github.com/JingyunLiang/SwinIR/blob/328dda0f4768772e6d8c5aa3d5aa8e24f1ad903b/utils/util_calculate_psnr_ssim.py#L80
def calculate_psnr(img1, img2, crop_border, input_order='HWC', test_y_channel=False):
"""Calculate PSNR (Peak Signal-to-Noise Ratio).
Re... | 9,023 | 37.564103 | 129 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/Image_denoising_figure2/Noisier2Noise/utils/metrics.py | import numpy as np
from skimage.metrics import peak_signal_noise_ratio, structural_similarity
def ssim(clean, noisy, normalized=True):
"""Use skimage.meamsure.compare_ssim to calculate SSIM
Args:
clean (Tensor): (B, C, H, W)
noisy (Tensor): (B, C, H, W)
normalized (bool): If True, the r... | 1,811 | 36.75 | 122 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/Image_denoising_figure2/Noisier2Noise/utils/__init__.py | from .train_utils import *
from .main_function_helpers import * | 63 | 31 | 36 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/Image_denoising_figure2/Noisier2Noise/utils/test_metrics.py | import torch
import numpy as np
import matplotlib.pyplot as plt
import glob
import os
#import cv2
from utils.noise_model import get_noise
from utils.metrics import ssim,psnr
from utils.util_calculate_psnr_ssim import calculate_psnr,calculate_ssim
from skimage import color
import PIL.Image as Image
import torchvision.tr... | 4,784 | 31.331081 | 119 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/Image_denoising_figure2/Noisier2Noise/utils/noise_model.py | import torch
def get_noise(data, noise_seed, fix_noise, noise_std = float(25)/255.0):
if fix_noise:
device = torch.device('cuda')
gen = torch.Generator(device=device)
batch_size = data.size(dim=0)
tensor_dim = list(data.size())[1:]
for i in range(0,batch_size)... | 880 | 31.62963 | 87 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/Image_denoising_figure2/Noisier2Noise/utils/meters.py | import time
import torch
class AverageMeter(object):
def __init__(self):
self.reset()
def reset(self):
self.val = 0
self.avg = 0
self.sum = 0
self.count = 0
def update(self, val, n=1):
if isinstance(val, torch.Tensor):
val = val.item()
... | 1,321 | 20.322581 | 75 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/Image_denoising_figure2/Noisier2Noise/utils/data_helpers/load_datasets_helpers.py | import os
import os.path
import numpy as np
import h5py
import torch
import torchvision.transforms as transforms
import PIL.Image as Image
from utils.utils_image import *
class ImagenetSubdataset(torch.utils.data.Dataset):
def __init__(self, size, path_to_ImageNet_train, mode='train', patch_size='128', val_crop=Tr... | 1,949 | 32.62069 | 131 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/Image_denoising_figure2/Neighbor2Neighbor/models/unet_fastMRI.py | """
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
import torch
import math
from torch import nn
from torch.nn import functional as F
class unet_fastMRI(nn.Module):
"""
PyTorch imple... | 7,138 | 34.517413 | 131 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/Image_denoising_figure2/Neighbor2Neighbor/models/__init__.py | from .unet_fastMRI import *
| 28 | 13.5 | 27 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/Image_denoising_figure2/Neighbor2Neighbor/utils/progress_bar.py | from collections import OrderedDict
from numbers import Number
from tqdm import tqdm
from .meters import AverageMeter, RunningAverageMeter, TimeMeter
class ProgressBar:
def __init__(self, iterable, epoch=None, prefix=None, quiet=False):
self.epoch = epoch
self.quiet = quiet
self.prefix = p... | 1,789 | 37.913043 | 115 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/Image_denoising_figure2/Neighbor2Neighbor/utils/utils_image.py | import os
import math
import random
import numpy as np
import torch
import cv2
from torchvision.utils import make_grid
def modcrop(img, scale):
# img_in: BCHW or CHW or HW
#img = np.copy(img_in)
if img.ndim == 2:
H, W = img.shape
H_r, W_r = H % scale, W % scale
img = img[:H - H_r, ... | 10,256 | 37.852273 | 99 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/Image_denoising_figure2/Neighbor2Neighbor/utils/train_utils.py | import argparse
import os
import logging
import numpy as np
import random
import sys
import torch
from datetime import datetime
from torch.serialization import default_restore_location
def add_logging_arguments(parser):
parser.add_argument("--seed", default=0, type=int, help="random number generator seed")
p... | 7,573 | 52.716312 | 138 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/Image_denoising_figure2/Neighbor2Neighbor/utils/main_function_helpers.py | import torch
import argparse
import os
import yaml
import pathlib
import pickle
import logging
import sys
import time
from torch.utils.tensorboard import SummaryWriter
import torch.nn.functional as F
import torchvision
import glob
from torch.serialization import default_restore_location
from torch.utils.data import Dat... | 29,827 | 45.244961 | 182 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/Image_denoising_figure2/Neighbor2Neighbor/utils/util_calculate_psnr_ssim.py | import cv2
import numpy as np
import torch
# from https://github.com/JingyunLiang/SwinIR/blob/328dda0f4768772e6d8c5aa3d5aa8e24f1ad903b/utils/util_calculate_psnr_ssim.py#L80
def calculate_psnr(img1, img2, crop_border, input_order='HWC', test_y_channel=False):
"""Calculate PSNR (Peak Signal-to-Noise Ratio).
Re... | 13,571 | 40.631902 | 151 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/Image_denoising_figure2/Neighbor2Neighbor/utils/metrics.py | import numpy as np
from skimage.metrics import peak_signal_noise_ratio, structural_similarity
def ssim(clean, noisy, normalized=True):
"""Use skimage.meamsure.compare_ssim to calculate SSIM
Args:
clean (Tensor): (B, C, H, W)
noisy (Tensor): (B, C, H, W)
normalized (bool): If True, the r... | 1,811 | 36.75 | 122 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/Image_denoising_figure2/Neighbor2Neighbor/utils/__init__.py | from .train_utils import *
from .main_function_helpers import * | 63 | 31 | 36 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/Image_denoising_figure2/Neighbor2Neighbor/utils/test_metrics.py | import torch
import numpy as np
import matplotlib.pyplot as plt
import glob
import os
#import cv2
from utils.noise_model import get_noise
from utils.metrics import ssim,psnr
from utils.util_calculate_psnr_ssim import calculate_psnr,calculate_ssim
from skimage import color
import PIL.Image as Image
import torchvision.tr... | 4,404 | 29.804196 | 119 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/Image_denoising_figure2/Neighbor2Neighbor/utils/noise_model.py | import torch
def get_noise(data, noise_seed, fix_noise, noise_std = float(25)/255.0):
if fix_noise:
device = torch.device('cuda')
gen = torch.Generator(device=device)
batch_size = data.size(dim=0)
tensor_dim = list(data.size())[1:]
for i in range(0,batch_size)... | 880 | 31.62963 | 87 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/Image_denoising_figure2/Neighbor2Neighbor/utils/meters.py | import time
import torch
class AverageMeter(object):
def __init__(self):
self.reset()
def reset(self):
self.val = 0
self.avg = 0
self.sum = 0
self.count = 0
def update(self, val, n=1):
if isinstance(val, torch.Tensor):
val = val.item()
... | 1,321 | 20.322581 | 75 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/Image_denoising_figure2/Neighbor2Neighbor/utils/data_helpers/load_datasets_helpers.py | import os
import os.path
import numpy as np
import h5py
import torch
import torchvision.transforms as transforms
import PIL.Image as Image
from utils.utils_image import *
class ImagenetSubdataset(torch.utils.data.Dataset):
def __init__(self, size, path_to_ImageNet_train, mode='train', patch_size='128', val_crop=Tr... | 1,949 | 32.62069 | 131 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/Image_denoising_figure2/Noise2Noise/models/unet_fastMRI.py | """
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
import torch
import math
from torch import nn
from torch.nn import functional as F
class unet_fastMRI(nn.Module):
"""
PyTorch imple... | 7,138 | 34.517413 | 131 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/Image_denoising_figure2/Noise2Noise/models/__init__.py | from .unet_fastMRI import * | 27 | 27 | 27 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/Image_denoising_figure2/Noise2Noise/utils/progress_bar.py | from collections import OrderedDict
from numbers import Number
from tqdm import tqdm
from .meters import AverageMeter, RunningAverageMeter, TimeMeter
class ProgressBar:
def __init__(self, iterable, epoch=None, prefix=None, quiet=False):
self.epoch = epoch
self.quiet = quiet
self.prefix = p... | 1,789 | 37.913043 | 115 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/Image_denoising_figure2/Noise2Noise/utils/utils_image.py | import os
import math
import random
import numpy as np
import torch
import cv2
from torchvision.utils import make_grid
def modcrop(img, scale):
# img_in: BCHW or CHW or HW
#img = np.copy(img_in)
if img.ndim == 2:
H, W = img.shape
H_r, W_r = H % scale, W % scale
img = img[:H - H_r, ... | 9,403 | 36.466135 | 99 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/Image_denoising_figure2/Noise2Noise/utils/train_utils.py | import argparse
import os
import logging
import numpy as np
import random
import sys
import torch
from datetime import datetime
from torch.serialization import default_restore_location
def add_logging_arguments(parser):
parser.add_argument("--seed", default=0, type=int, help="random number generator seed")
p... | 7,573 | 52.716312 | 138 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/Image_denoising_figure2/Noise2Noise/utils/main_function_helpers.py | import torch
import argparse
import os
import yaml
import pathlib
import pickle
import logging
import sys
import time
from torch.utils.tensorboard import SummaryWriter
import torch.nn.functional as F
import torchvision
import glob
from torch.serialization import default_restore_location
from torch.utils.data import Dat... | 23,245 | 45.772636 | 182 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/Image_denoising_figure2/Noise2Noise/utils/util_calculate_psnr_ssim.py | import cv2
import numpy as np
import torch
# from https://github.com/JingyunLiang/SwinIR/blob/328dda0f4768772e6d8c5aa3d5aa8e24f1ad903b/utils/util_calculate_psnr_ssim.py#L80
def calculate_psnr(img1, img2, crop_border, input_order='HWC', test_y_channel=False):
"""Calculate PSNR (Peak Signal-to-Noise Ratio).
Re... | 9,023 | 37.564103 | 129 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/Image_denoising_figure2/Noise2Noise/utils/metrics.py | import numpy as np
from skimage.metrics import peak_signal_noise_ratio, structural_similarity
def ssim(clean, noisy, normalized=True):
"""Use skimage.meamsure.compare_ssim to calculate SSIM
Args:
clean (Tensor): (B, C, H, W)
noisy (Tensor): (B, C, H, W)
normalized (bool): If True, the r... | 1,811 | 36.75 | 122 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/Image_denoising_figure2/Noise2Noise/utils/__init__.py | from .train_utils import *
from .main_function_helpers import * | 63 | 31 | 36 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/Image_denoising_figure2/Noise2Noise/utils/test_metrics.py | import torch
import numpy as np
import matplotlib.pyplot as plt
import glob
import os
#import cv2
from utils.noise_model import get_noise
from utils.metrics import ssim,psnr
from utils.util_calculate_psnr_ssim import calculate_psnr,calculate_ssim
from skimage import color
import PIL.Image as Image
import torchvision.tr... | 4,464 | 29.582192 | 119 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/Image_denoising_figure2/Noise2Noise/utils/noise_model.py | import torch
def get_noise(data, noise_seed, fix_noise, noise_std = float(25)/255.0):
if fix_noise:
device = torch.device('cuda')
gen = torch.Generator(device=device)
batch_size = data.size(dim=0)
tensor_dim = list(data.size())[1:]
for i in range(0,batch_size)... | 880 | 31.62963 | 87 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/Image_denoising_figure2/Noise2Noise/utils/meters.py | import time
import torch
class AverageMeter(object):
def __init__(self):
self.reset()
def reset(self):
self.val = 0
self.avg = 0
self.sum = 0
self.count = 0
def update(self, val, n=1):
if isinstance(val, torch.Tensor):
val = val.item()
... | 1,321 | 20.322581 | 75 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/Image_denoising_figure2/Noise2Noise/utils/data_helpers/load_datasets_helpers.py | import os
import os.path
import numpy as np
import h5py
import torch
import torchvision.transforms as transforms
import PIL.Image as Image
from utils.utils_image import *
class ImagenetSubdataset(torch.utils.data.Dataset):
def __init__(self, size, path_to_ImageNet_train, mode='train', patch_size='128', val_crop=Tr... | 1,949 | 32.62069 | 131 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/CS_natural_images_figure4/train_network_for_histogram.py | # %%
import torch
import h5py
import numpy as np
import os
import yaml
import logging
import glob
import random
import pickle
from typing import Callable, Dict, List, Optional, Sequence, Tuple, Union
import matplotlib.pyplot as plt
from torch.nn import MSELoss
import copy
from argparse import ArgumentParser
from torc... | 21,063 | 36.681574 | 211 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/CS_natural_images_figure4/run_CS_natural_images.py | # %%
import torch
import h5py
import numpy as np
import os
import yaml
import logging
import glob
import json
import random
import pickle
from typing import Callable, Dict, List, Optional, Sequence, Tuple, Union
import matplotlib.pyplot as plt
from torch.nn import MSELoss
from argparse import ArgumentParser
from torc... | 29,149 | 44.404984 | 278 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/CS_natural_images_figure4/CS_natural_images_functions/progress_bar.py | from collections import OrderedDict
from numbers import Number
from tqdm import tqdm
import torch
import logging
import os
import numpy as np
def init_logging(experiment_path):
for handler in logging.root.handlers[:]:
logging.root.removeHandler(handler)
handlers = [logging.StreamHandler()]
mode = ... | 3,573 | 30.910714 | 127 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/CS_natural_images_figure4/CS_natural_images_functions/losses.py | """
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
import torch
import torch.nn as nn
import torch.nn.functional as F
class SSIMLoss(nn.Module):
"""
SSIM loss module.
"""
de... | 1,849 | 31.45614 | 98 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/CS_natural_images_figure4/CS_natural_images_functions/load_save_model_helpers.py | import glob
import torch
import os
from torch.serialization import default_restore_location
import logging
def setup_experiment_or_load_checkpoint(experiment_path, resume_from='best', model=None, optimizer=None, scheduler=None):
'''
Args:
- resume_from: Either 'best' or 'some_number' where some_number ... | 4,690 | 45.445545 | 154 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/CS_natural_images_figure4/CS_natural_images_functions/unet.py | """
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
import torch
from torch import nn
from torch.nn import functional as F
class Unet(nn.Module):
"""
PyTorch implementation of a U-Net... | 6,021 | 31.907104 | 113 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/CS_natural_images_figure4/CS_natural_images_functions/fftc.py | """
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
from typing import List, Optional
import torch
import torch.fft # type: ignore
def fft2c(data: torch.Tensor) -> torch.Tensor:
"""
... | 4,108 | 23.753012 | 80 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/CS_natural_images_figure4/CS_natural_images_functions/data_transforms.py | import numpy as np
import torch
from typing import Callable, Dict, List, Optional, Sequence, Tuple, Union
import torchvision.transforms as transforms
import PIL.Image as Image
from CS_natural_images_functions.log_progress_helpers import save_figure
from CS_natural_images_functions.fftc import fft2c, ifft2c
class C... | 8,047 | 36.432558 | 141 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/CS_natural_images_figure4/CS_natural_images_functions/log_progress_helpers.py | import numpy as np
import matplotlib.pyplot as plt
from typing import Dict, Optional, Sequence, Tuple, Union, List
import os
import torchvision
import io
import torch
from CS_natural_images_functions.losses import SSIMLoss
def complex_abs(data: torch.Tensor) -> torch.Tensor:
"""
Compute the absolute value of ... | 8,395 | 35.663755 | 162 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/CS_accelerated_MRI_figure5/run_MRI.py | # %%
##################################
# Import python packages
import numpy as np
import os
import traceback
# Import main()
from functions.main import main_train, main_test
#from functions.train_utils import get_event_details
os.environ['CUDA_VISIBLE_DEVICES'] = '3'
# %%
##################################
# Cust... | 11,447 | 44.070866 | 230 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/CS_accelerated_MRI_figure5/functions/main.py |
#################
# Import python packages
import torch
import logging
import time
from torch.utils.tensorboard import SummaryWriter
import sys
import os
from torch.serialization import default_restore_location
from collections import defaultdict
import numpy as np
import torchvision
import pickle
import matplotlib.py... | 40,715 | 45.961938 | 214 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/CS_accelerated_MRI_figure5/functions/coil_combine.py | """
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
import torch
from functions.math import complex_abs_sq
def rss(data: torch.Tensor, dim: int = 0) -> torch.Tensor:
"""
Compute the ... | 1,015 | 22.627907 | 66 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/CS_accelerated_MRI_figure5/functions/math.py | """
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
import numpy as np
import torch
def complex_mul(x: torch.Tensor, y: torch.Tensor) -> torch.Tensor:
"""
Complex multiplication.
... | 2,728 | 25.754902 | 77 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/CS_accelerated_MRI_figure5/functions/log_save_image_utils.py | import matplotlib.pyplot as plt
import torchvision
import io
import torch
import numpy as np
def plot_to_image(figure):
"""Converts the matplotlib plot specified by 'figure' to a PNG image and
returns it. The supplied figure is closed and inaccessible after this call."""
# Save the plot to a PNG in memory.... | 1,533 | 33.088889 | 91 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/CS_accelerated_MRI_figure5/functions/train_utils.py |
import torch
import numpy as np
import random
import os
import glob
import logging
from torch.serialization import default_restore_location
from tensorboard.backend.event_processing import event_accumulator
import time
import matplotlib.pyplot as plt
def setup_experiment(hp_exp):
'''
- Handle seeding
- Cr... | 7,597 | 44.771084 | 160 | py |
sample_complexity_ss_recon | sample_complexity_ss_recon-main/CS_accelerated_MRI_figure5/functions/fftc.py | """
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
from typing import List, Optional
import torch
from packaging import version
if version.parse(torch.__version__) >= version.parse("1.7.0"):... | 5,535 | 25.236967 | 80 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.