Contrastive_Model_net.py - cmikke97/Automatic-Malware-Signature-Generation GitHub Wiki

In this page

Imported Modules

  • import configparser - implements a basic configuration language for Python programs - configparser documentation
  • import os - provides a portable way of using operating system dependent functionality - os documentation

  • from torch import nn - a neural network library deeply integrated with autograd designed for maximum flexibility - torch.nn documentation

  • from .utils.Net import Net as baseNet

Back to top

Classes and functions

Net (class) - Contrastive (Siamese) Network built using the MTJE model as base and optimized using the Online Triplet Loss.

  • __init__(self, feature_dimension, embedding_dimension, layer_sizes, dropout_p, activation_function, normalization_function) (member function) - Initialize net.
    • feature_dimension (arg) - Dimension of the input data feature vector (default: 2381)
    • embedding_dimension (arg) - Latent space size (unused) (default: 32)
    • layer_sizes (arg) - Layer sizes (array of sizes) (default: None -> use [128, 64])
    • dropout_p (arg) - Dropout probability (default: 0.05)
    • activation_function (arg) - Non-linear activation function to use (may be "elu", "leakyRelu", "pRelu" or "relu") (default: "elu")
    • normalization_function (arg) - Normalization function to use (may be "layer_norm" or "batch_norm") (default: "batch_norm")
  • forward(self, data) (member function) - Forward batch of data through the net.
    • data (arg) - Current batch of data (features)
  • compute_loss(predictions, labels, loss_wts) (static member function) - Compute Net loss. Not Implemented. Defined here to make this class compatible to the Net class.
    • predictions (arg) - A dictionary of results from the Net
    • labels (arg) - A dictionary of labels
    • loss_wts (arg) - Weights to assign to each head of the network (if it exists); defaults to values used in the ALOHA paper (1.0 for malware, 0.1 for count and each tag)
  • normalize_results(labels_dict, results_dict, use_malware, use_count, use_tags) (static member function) - Take a set of results dicts and break them out into a single dict of 1d arrays with appropriate column names that pandas can convert to a DataFrame. Not Implemented. Defined here to make this class compatible to the Net class.
    • labels_dict (arg) - Labels (ground truth) dictionary
    • results_dict (arg) - Results (predicted labels) dictionary
    • use_malware (arg) - Whether to use malware/benignware labels as a target (default: False)
    • use_count (arg) - Whether to use the counts as an additional target (default: False)
    • use_tags (arg) - Whether to use SMART tags as additional targets (default: False)

Back to top

⚠️ **GitHub.com Fallback** ⚠️