Comments (5)
Good morning!
Training and fine-tuning of models is not yet implemented (the library is solely for evasion attacks).
However, if you would like to add this functionality, you can consider opening a pull request with that!
from secml_malware.
Getting error in training model when using embed function
print("ok inside train 1")
try:
print("global_state.data_paths ", global_state.data_paths)
for file_path in path:
with open(file_path, 'rb') as handle:
bytecode = handle.read()
print("ok inside train 2")
print("global_state.target ", global_state.target)
net: CClassifierEnd2EndMalware = global_state.target
x = End2EndModel.bytes_to_numpy(bytecode, net.get_input_max_length(), net.get_embedding_value(),
net.get_is_shifting_values())
model = MalConv()
model.train(True)
criterion = nn.BCELoss()
optimizer = Adam(model.parameters(), lr=0.01)
scheduler = ReduceLROnPlateau(optimizer, patience=3, verbose=True, factor=0.5,
threshold=0.001, min_lr=0.00001, mode='max')
print("ok inside train 3")
epochs = 3
y_pred = 0
for epoch in range(epochs):
y_pred = model.embedd_and_forward(model.embed(x))
loss = criterion(y_pred, label)
optimizer.zero_grad()
loss.backward()
optimizer.step()
model.eval()
print("ok inside train 8")
scheduler.step(f1_score(label, y_pred))
print("ok inside train 4")
except Exception as e:
print(e)
return model
Getting error : "Dimension out of range (expected to be in range of [-1, 0], but got 1)"
Can you help to resolve this
Thanks
from secml_malware.
Hello,
Probably y_train is just a number and not a batch as expected by the loss.
Check which shapes the loss needs first, let me know!
from secml_malware.
Thanks got that cleared now my malconv model is predicting as trained but when I see the output it doesn't have prediction properly printed.
def _perform_optimization(attack, file_path, stats, x, y):
print('-' * 10)
info_prompt(f'Processing {file_path}...')
y_pred, adv_score, adv_ds, f_obj = attack.run(x, y)
y_pred = y_pred.item()
score = adv_score[0, 1].item()
stats['evasion'] += (1 - y_pred)
stats['total'] += 1
stats['adv_score'] += score
net = create_wrapper_for_global_target()
_, original_score = net.predict(x, return_decision_function=True)
stats['before_score'] += original_score[0, 1]
info_prompt(f'Results for {file_path}')
info_prompt(f'Final label: {y_pred}')
info_prompt(f'Initial score: {original_score}')
info_prompt(f'Final score: {score}')
return adv_ds
In the above code in line : _, original_score = net.predict(x, return_decision_function=True)
the first argument is the prediction label but it is not we are printing may I know the reason?
from secml_malware.
I don't think I got the question: if you set the "return_decision_function" to True, the output is the prediction and the score. The prediction is "score > threshold", hence 1 if malware, 0 if goodware.
Score is a CArray with two entries: first is goodware score, the second is malware (and they sum to 1)
from secml_malware.
Related Issues (20)
- How to run lightGBM and SOREL model using secml_malware? HOT 2
- No data preprocessing for SorelNet? HOT 2
- Error while running the sample attack code from blackbox_tutorial.ipynb HOT 4
- real sample generation HOT 5
- can't attack EMBER model HOT 1
- Confidence on Microsoft Malware Classification Challenge HOT 10
- Differences Between WhiteBox Attacks HOT 7
- Adding support for QuoVadis models HOT 2
- AttributeError: 'NoneType' object has no attribute 'dos_header' HOT 4
- No such file or directory: 'secml_malware/data/malware_samples/test_folder' HOT 3
- lightGBM and SOREL model weights? HOT 1
- Support for ensemble models HOT 1
- SOREL ATTACK HOT 1
- CGammaSectionsEvasionProblem attack budget HOT 6
- FGSM Attacking Running for days HOT 1
- Fix numpy retrocompatibility for CClassifierEmber
- issue installing secml-malware with pip with python 3.12
- Wrong ember prediction
- GAMMA section injections might load sections at random
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from secml_malware.