Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View Tandon-A's full-sized avatar

Abhishek Tandon Tandon-A

View GitHub Profile
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()
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]
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))
import argparse
import cv2
import numpy as np
import os
import pandas as pd
def parse_args():
''' Argument Parser. '''
parser = argparse.ArgumentParser()