This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import cv2 | |
import numpy as np | |
import os | |
import pandas as pd | |
def parse_args(): | |
''' Argument Parser. ''' | |
parser = argparse.ArgumentParser() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def analysis(db_size,query,noise_percentage=0.5): | |
db = create_db(db_size) | |
augmented_db = modify_db(db,noise_percentage) | |
true_output = query(db) | |
augmented_output = query(augmented_db) | |
analysis_output = (augmented_output - (1 - noise_percentage) * 0.5)/noise | |
print ("size = %r orginal_db result = %r augmented_db result = %r deskewed analysis result = %r" %(db_size,true_output,augmented_output,analysis_output)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def modify_db(db,noise=0.5): | |
first_coin_flip = (torch.rand(len(db)) < noise).float() | |
second_coin_flip = (torch.rand(len(db)) < 0.5).float() | |
augmented_database = db.float()*first_coin_flip + (1-first_coin_flip)*second_coin_flip | |
#augmented database can also be created using this other way | |
''' | |
augmented_database = db.copy() | |
augmented_database[first_coin_flip == 0] = second_coin_flip[first_coin_flip == 0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
def create_db(db_size): | |
db = torch.rand(n) >= 0.5 | |
return db | |
def modify_db(db,noise=0.5): | |
first_coin_flip = (torch.rand(len(db)) < noise).float() | |
second_coin_flip = (torch.rand(len(db)) < 0.5).float() | |