-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plan for the pipeline [UPDATED] #79
Comments
from decepticonlp import attack
from keras.datasets import imdb
import torch #can be keras / tf
#Load Data
train, test = imdb.load_data()
#Generate Adversaries
#grid will be params consisting of metrics, transforms
attacker = attack.decepticon(task="classification", method="single_pass")
adversaries = attacker.generate_from_grid(train, grid, top_k=3)
adversaries_list = adversaries.get_list() #returns list of datasets/dataloaders
#Load Model
MODEL_PATH = "PATH_TO_MODEL"
model = torch.load(MODEL_PATH)
#Import inference class / User implements his own loop
from user_model import test
#Display results
results = adversaries.evaluate(test)
results.show()
#IMPORTANT
#For methods that receive the classification labels / translated text etc
#Intit attacker and training setup
attacker = attack.decepticon(task="classification", method="train")
attacker.set_grid_trainer(train, grid, test)
attacker.train(epochs=10, **kwargs) #train
#Generate Adversaries
adversaries = attacker.generate_from_trainer(top_k=3)
adversaries_list = adversaries.get_list() #returns list of datasets/dataloaders
#Display results
results = adversaries.evaluate(test)
results.show() |
If the tasks look separate enough please ping me, I will separate the trainer and single pass method |
@someshsingh22 @rajaswa A few questions. Suppose:
... (1) Now, we intend to generate top_k adversaries based on the accuracy computed (lower the accuracy --> better the adversary). But to compute accuracy, we will need to do a forward pass. Where do we do that? We do it later:
Won't we have to pass the user's loop in (1), however, in order to compute metrics like accuracy/F1 Score? |
Top K is for showing the results, the metrics will be computed in results.evaluate(test) where test is the user's loop |
I will put the assumed pseudocode as well first let's discuss the features / plan in words
NOTE : THIS IS FOR SINGLE PASS ATTACKS ONLY
We missed out on approaches where Black box attacks get classification results from models
SINGLE PASS
Implement Classification, Translation, NER, Entailment in order
Add standard datasets of each type IMDB, English-Chinese SST etc
We can offer our own as well Torchtext/Allennlp
User can define his own dataloaders
Data Loaders / Datasets keeping option (2) in mind and give user an option of top k attacks to be kept
Give users a grid option for metrics, extractors, and transforms
Show user the ETA
Show top k best attacks and their results.
TRAIN
Pass the test function to the trainer along with grid to the grid trainer
Additional - Can add three version of decepticons, strong, stealthy and balanced top_k rankings will be done on basis of fall of accuracy (fall), metric distance, weighted-mean
The text was updated successfully, but these errors were encountered: