Skip to content

Instantly share code, notes, and snippets.

@Tandon-A
Last active September 9, 2019 13:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tandon-A/334efacbd79e927fbf420ab5e43e7239 to your computer and use it in GitHub Desktop.
Save Tandon-A/334efacbd79e927fbf420ab5e43e7239 to your computer and use it in GitHub Desktop.
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]
'''
return augmented_database
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment