From 9802dd9a80052501e1c6f2ff86fb851d46375b13 Mon Sep 17 00:00:00 2001 From: aryanxk02 Date: Mon, 11 Mar 2024 12:47:47 +0530 Subject: [PATCH 1/2] Create summaries for all projects --- Top10MLSummary.md | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 Top10MLSummary.md diff --git a/Top10MLSummary.md b/Top10MLSummary.md new file mode 100644 index 0000000..266413a --- /dev/null +++ b/Top10MLSummary.md @@ -0,0 +1,47 @@ +## ML01:2023 Input Manipulation Attack + +Input Manipulation Attacks involve changing input data to trick models, with Adversarial Attacks being a key tactic. Prevention methods include training models with deceptive examples (Adversarial Training), using robust models resistant to manipulation, and employing input validation to detect and reject potentially harmful inputs. + + +## ML02:2023 Data Poisoning Attack +Data poisoning attacks involve manipulating training data to influence model behavior negatively. Prevention methods include thorough validation and verification of training data, secure storage practices, data separation, access controls, monitoring, auditing, model validation with separate sets, model ensembles, and anomaly detection to identify abnormal behavior. + + + +## ML03:2023 Model Inversion Attack + +Model inversion attacks involve extracting information from models by reverse-engineering them. Prevention includes restricting access, validating inputs, ensuring model transparency, regular monitoring, and retraining models. Vigilant implementation of these measures is crucial to safeguard against such attacks. + + +## ML04:2023 Membership Inference Attack + +Membership inference attacks involve manipulating a model's training data to expose sensitive information. Prevention methods include training models on randomized data, obfuscating predictions with noise or differential privacy, regularization techniques, reducing training data size, and testing and monitoring for anomalies to thwart such attacks. + + +## ML05:2023 Model Theft + +Model theft attacks involve unauthorized access to a model's parameters. Prevention methods include encryption of sensitive information, strict access controls, regular backups, code obfuscation, watermarking, legal protection, and monitoring/auditing to detect and prevent theft attempts. + +## ML06:2023 AI Supply Chain Attacks + +AI Supply Chain Attacks involve tampering with machine learning libraries or models used by a system, including associated data. Prevention involves verifying package signatures, using secure repositories like Anaconda, keeping packages updated, employing virtual environments, conducting code reviews, utilizing package verification tools like PEP 476, Secure Package Install, and educating developers on the risks. + + +## ML07:2023 Transfer Learning Attack + +Transfer learning attacks involve training a model on one task and fine-tuning it on another to cause undesirable behavior. Prevention methods include monitoring and updating training datasets regularly, using secure and trusted datasets, implementing model isolation, employing differential privacy, and conducting regular security audits to identify and address vulnerabilities. + + +## ML08:2023 Model Skewing + +Model skewing attacks involve manipulating the distribution of training data to induce undesirable model behavior. Prevention strategies include implementing robust access controls, verifying the authenticity of feedback data, employing data validation and cleaning techniques, implementing anomaly detection, regularly monitoring model performance, and continuously training the model with updated and verified data. + + +## ML09:2023 Output Integrity Attack + +In an Output Integrity Attack, an attacker aims to manipulate a machine learning model's output to cause harm. Prevention methods include using cryptographic techniques for result authenticity verification, securing communication channels, input validation, maintaining tamper-evident logs, regular software updates, and monitoring and auditing for suspicious activities. + + +## ML10:2023 Model Poisoning + +Model poisoning attacks involve manipulating a model's parameters to induce undesirable behavior. Prevention methods include regularization techniques to mitigate overfitting, designing robust model architectures and activation functions, and employing cryptographic techniques to secure model parameters from unauthorized access or manipulation. From edc5356c9def3dc313a0f78c8744ea14ecae1392 Mon Sep 17 00:00:00 2001 From: aryanxk02 Date: Sat, 16 Mar 2024 00:44:51 +0530 Subject: [PATCH 2/2] feat: add cheatseet for ML07 --- ...023-Transfer-Learning-Attack-Cheatsheet.md | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 docs/cheatsheets/ML02_2023-Transfer-Learning-Attack-Cheatsheet.md diff --git a/docs/cheatsheets/ML02_2023-Transfer-Learning-Attack-Cheatsheet.md b/docs/cheatsheets/ML02_2023-Transfer-Learning-Attack-Cheatsheet.md new file mode 100644 index 0000000..26841c3 --- /dev/null +++ b/docs/cheatsheets/ML02_2023-Transfer-Learning-Attack-Cheatsheet.md @@ -0,0 +1,72 @@ +### Transfer Learning in Machine Learning Cheat Sheet + +#### Introduction +Transfer learning (TL) is a machine learning (ML) technique that uses a previously trained model as the base for building a new model for a different task. The model is trained using less data for the new task. TL is a popular approach in deep learning because it can train deep neural networks with less data than building a model from scratch. + +This cheat sheet provides concise guidance for implementing Transfer Learning in Machine Learning models via Keras and TensorFlow. + +#### Goals of Transfer Learning +- Speed up training by initializing models with pre-learned parameters. +- Improve performance on new tasks using knowledge from related tasks. +- Enable effective learning with limited labeled data by transferring knowledge from large datasets. + +#### Strategies +1. **Feature Extraction**: Freeze early layers of pre-trained models and extract learned features for new tasks. +2. **Fine-tuning**: Unfreeze some layers of pre-trained models and continue training with new data to adapt to specific tasks. +3. **Domain Adaptation**: Adjust pre-trained models to new domains by transferring knowledge while minimizing domain shift. +4. **Multi-task Learning**: Train models to perform multiple tasks simultaneously, leveraging shared representations for improved performance. + +#### Implementation +```python +import tensorflow as tf +from tensorflow.keras.applications import ResNet50 +from tensorflow.keras.layers import Dense, Flatten +from tensorflow.keras.models import Model +``` +This code snippet contains code for TensorFlow library and its components used for building a deep learning model based on the ResNet50 architecture. + +```python +# Load pre-trained ResNet50 model +base_model = ResNet50(weights='imagenet', include_top=False, input_shape=(224, 224, 3)) +``` +Pre-trained ResNet50 model is loaded using TensorFlow's Keras API. The pre-trained model is obtained from the ImageNet dataset, a large-scale image database used for training convolutional neural networks. +```python +# Freeze early layers for feature extraction +for layer in base_model.layers: + layer.trainable = False +``` +Freezing layers in a pre-trained model is beneficial when using transfer learning, where the model's knowledge learned from a source task (e.g., ImageNet classification) is transferred to a different target task (e.g., a specific image classification task). By freezing the layers, the model retains its feature extraction capabilities while allowing users to add custom layers for the target task without affecting the pre-trained weights. +```python +# Add custom classifier on top +x = Flatten()(base_model.output) +x = Dense(256, activation='relu')(x) +predictions = Dense(num_classes, activation='softmax')(x) + +# Create new model +model = Model(inputs=base_model.input, outputs=predictions) +``` +The new model can be trained using a suitable optimizer and loss function for the target classification task. Since the base layers are frozen, only the custom classification layers will be trained, preserving the knowledge learned by the pre-trained ResNet50 model. This approach is commonly used in transfer learning scenarios to adapt pre-trained models to new tasks efficiently. + + +```python +# Compile model +model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy']) + +# Train model on new data +model.fit(train_data, train_labels, epochs=10, batch_size=32, validation_data=(val_data, val_labels)) +``` +### Best Practices + +**Data Augmentation**: Increase diversity and generalize better, especially with limited labeled data. + +**Regularization**: Prevent overfitting during fine-tuning with techniques like dropout or weight decay. + +**Transfer Subset of Layers**: Avoid overfitting or loss of information by transferring only relevant layers. + +**Monitor Performance**: Continuously monitor model performance and adjust training strategy accordingly. + +**Experiment with Architectures**: Explore different architectures and pre-trained models for best performance. + +### Conclusion +Transfer Learning enables efficient model training and improved performance on new tasks. By following best practices and experimenting with different techniques, practitioners can effectively apply transfer learning to various machine learning tasks. +