Skip to content

Commit

Permalink
Merge pull request #11 from pralab/secml2rename
Browse files Browse the repository at this point in the history
Changing name of the package from src to secml2
  • Loading branch information
maurapintor authored Sep 21, 2023
2 parents bbaa69c + ad2cb76 commit 5f0ee0a
Show file tree
Hide file tree
Showing 43 changed files with 63 additions and 63 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,4 @@ $RECYCLE.BIN/
*.msp

# Windows shortcuts
*.lnk

models/
*.lnk
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

from torch.utils.data import DataLoader

from src.adv.backends import Backends
from src.adv.evasion.perturbation_models import PerturbationModels
from src.models.base_model import BaseModel
from secml2.adv.backends import Backends
from secml2.adv.evasion.perturbation_models import PerturbationModels
from secml2.models.base_model import BaseModel


class BaseEvasionAttackCreator:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

import torch.nn
from torch.nn import CrossEntropyLoss
from torch.optim import Adam, SGD
from torch.optim import Adam, SGD, Optimizer
from torch.utils.data import DataLoader, TensorDataset

from src.adv.evasion.base_evasion_attack import BaseEvasionAttack
from src.manipulations.manipulation import Manipulation
from src.models.base_model import BaseModel
from src.optimization.constraints import Constraint
from src.optimization.gradient_processing import GradientProcessing
from src.optimization.initializer import Initializer
from secml2.adv.evasion.base_evasion_attack import BaseEvasionAttack
from secml2.manipulations.manipulation import Manipulation
from secml2.models.base_model import BaseModel
from secml2.optimization.constraints import Constraint
from secml2.optimization.gradient_processing import GradientProcessing
from secml2.optimization.initializer import Initializer

CE_LOSS = "ce_loss"
LOGITS_LOSS = "logits_loss"
Expand All @@ -32,7 +32,7 @@ def __init__(
num_steps: int,
step_size: float,
loss_function: Union[str, torch.nn.Module],
optimizer_cls: Union[str, Type[torch.nn.Module]],
optimizer_cls: Union[str, Type[Optimizer]],
manipulation_function: Manipulation,
domain_constraints: List[Constraint],
perturbation_constraints: List[Type[Constraint]],
Expand Down
8 changes: 4 additions & 4 deletions src/adv/evasion/foolbox.py → secml2/adv/evasion/foolbox.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from typing import Optional
from src.adv.evasion.base_evasion_attack import BaseEvasionAttack
from secml2.adv.evasion.base_evasion_attack import BaseEvasionAttack
from foolbox.attacks.base import Attack
from torch.utils.data import DataLoader
from src.models.base_model import BaseModel
from src.models.pytorch.base_pytorch_nn import BasePytorchClassifier
from src.models.base_model import BaseModel
from secml2.models.base_model import BaseModel
from secml2.models.pytorch.base_pytorch_nn import BasePytorchClassifier
from secml2.models.base_model import BaseModel
from foolbox.models.pytorch import PyTorchModel
from foolbox.criteria import Misclassification, TargetedMisclassification
import torch
Expand Down
File renamed without changes.
20 changes: 10 additions & 10 deletions src/adv/evasion/pgd.py → secml2/adv/evasion/pgd.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
import torch
from torch.optim import Adam

from src.adv.evasion.composite_attack import CompositeEvasionAttack, CE_LOSS, SGD
from src.manipulations.manipulation import AdditiveManipulation
from src.optimization.initializer import Initializer
from src.optimization.gradient_processing import LinearProjectionGradientProcessing
from src.adv.evasion.foolbox import BaseFoolboxEvasionAttack

from src.adv.evasion.perturbation_models import PerturbationModels
from src.adv.backends import Backends
from src.adv.evasion.base_evasion_attack import (
from secml2.adv.evasion.composite_attack import CompositeEvasionAttack, CE_LOSS, SGD
from secml2.manipulations.manipulation import AdditiveManipulation
from secml2.optimization.initializer import Initializer
from secml2.optimization.gradient_processing import LinearProjectionGradientProcessing
from secml2.adv.evasion.foolbox import BaseFoolboxEvasionAttack

from secml2.adv.evasion.perturbation_models import PerturbationModels
from secml2.adv.backends import Backends
from secml2.adv.evasion.base_evasion_attack import (
BaseEvasionAttackCreator,
)

Expand All @@ -21,7 +21,7 @@
LinfProjectedGradientDescentAttack,
)

from src.optimization.constraints import (
from secml2.optimization.constraints import (
ClipConstraint,
L1Constraint,
L2Constraint,
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
import torch
import torchvision.datasets
from torch.utils.data import DataLoader, Subset
from src.adv.backends import Backends
from src.adv.evasion.pgd import PGD
from src.adv.evasion.perturbation_models import PerturbationModels
from secml2.adv.backends import Backends
from secml2.adv.evasion.pgd import PGD
from secml2.adv.evasion.perturbation_models import PerturbationModels

from src.metrics.classification import Accuracy
from src.models.pytorch.base_pytorch_nn import BasePytorchClassifier
from secml2.metrics.classification import Accuracy
from secml2.models.pytorch.base_pytorch_nn import BasePytorchClassifier

from torch import nn

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import torch
import torchvision.datasets
from torch.utils.data import DataLoader, Subset
from src.adv.backends import Backends
from src.adv.evasion.pgd import PGD
from src.adv.evasion.perturbation_models import PerturbationModels
from secml2.adv.backends import Backends
from secml2.adv.evasion.pgd import PGD
from secml2.adv.evasion.perturbation_models import PerturbationModels

from src.metrics.classification import Accuracy
from src.models.pytorch.base_pytorch_nn import BasePytorchClassifier
from secml2.metrics.classification import Accuracy
from secml2.models.pytorch.base_pytorch_nn import BasePytorchClassifier

from robustbench.utils import load_model

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from torch.optim import Adam
from torch.utils.data import DataLoader

from src.metrics.classification import Accuracy
from src.models.pytorch.base_pytorch_nn import BasePytorchClassifier
from src.models.pytorch.base_pytorch_trainer import BasePyTorchTrainer
from secml2.metrics.classification import Accuracy
from secml2.models.pytorch.base_pytorch_nn import BasePytorchClassifier
from secml2.models.pytorch.base_pytorch_trainer import BasePyTorchTrainer


class MNISTNet(torch.nn.Module):
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import torch
from torch.utils.data import DataLoader

from src.models.base_model import BaseModel
from secml2.models.base_model import BaseModel


def accuracy(y_pred: torch.Tensor, y_true: torch.Tensor) -> torch.Tensor:
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 4 additions & 2 deletions src/models/base_model.py → secml2/models/base_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
import torch
from torch.utils.data import DataLoader

from src.models.data_processing.identity_data_processing import IdentityDataProcessing
from src.models.data_processing.data_processing import DataProcessing
from secml2.models.data_processing.identity_data_processing import (
IdentityDataProcessing,
)
from secml2.models.data_processing.data_processing import DataProcessing


class BaseModel(ABC):
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import torch

from src.models.data_processing.data_processing import DataProcessing
from secml2.models.data_processing.data_processing import DataProcessing


class IdentityDataProcessing(DataProcessing):
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import torch
from torch.utils.data import DataLoader

from src.models.base_model import BaseModel
from src.models.data_processing.data_processing import DataProcessing
from src.models.pytorch.base_pytorch_trainer import BasePyTorchTrainer
from secml2.models.base_model import BaseModel
from secml2.models.data_processing.data_processing import DataProcessing
from secml2.models.pytorch.base_pytorch_trainer import BasePyTorchTrainer


class BasePytorchClassifier(BaseModel):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from torch.optim.lr_scheduler import _LRScheduler # noqa
from torch.utils.data import DataLoader

from src.models.base_trainer import BaseTrainer
from secml2.models.base_trainer import BaseTrainer


class BasePyTorchTrainer(BaseTrainer):
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import torch
from torch.optim import Adam

from src.models.pytorch.base_pytorch_nn import BasePytorchClassifier
from src.models.pytorch.base_pytorch_trainer import BasePyTorchTrainer
from src.models.pytorch.test.base_pytorch import BasePytorchTests
from secml2.models.pytorch.base_pytorch_nn import BasePytorchClassifier
from secml2.models.pytorch.base_pytorch_trainer import BasePyTorchTrainer
from secml2.models.pytorch.test.base_pytorch import BasePytorchTests


class TestPytorchNN(BasePytorchTests):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from torch.optim import Adam

from src.models.pytorch.base_pytorch_trainer import BasePyTorchTrainer
from src.models.pytorch.test.base_pytorch import BasePytorchTests
from secml2.models.pytorch.base_pytorch_trainer import BasePyTorchTrainer
from secml2.models.pytorch.test.base_pytorch import BasePytorchTests


class TestPytorchTrainer(BasePytorchTests):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import torch
from torch.utils.data import DataLoader

from src.data.sklearn_dataset import SklearnDataset
from src.models.base_model import BaseModel
from src.models.data_processing.data_processing import DataProcessing
from secml2.data.sklearn_dataset import SklearnDataset
from secml2.models.base_model import BaseModel
from secml2.models.data_processing.data_processing import DataProcessing


class BaseSklearnModel(BaseModel):
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import tensorflow as tf
import torch

from src.models.base_model import BaseModel
from src.models.data_processing.data_processing import DataProcessing
from src.models.tensorflow.base_tensorflow_trainer import BaseTensorflowTrainer
from secml2.models.base_model import BaseModel
from secml2.models.data_processing.data_processing import DataProcessing
from secml2.models.tensorflow.base_tensorflow_trainer import BaseTensorflowTrainer


class BaseTensorflowClassifier(BaseModel):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from src.models.base_trainer import BaseTrainer
from secml2.models.base_trainer import BaseTrainer


class BaseTensorflowTrainer(BaseTrainer):
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import torch.linalg
from torch.nn.functional import normalize

from src.adv.evasion.perturbation_models import PerturbationModels
from secml2.adv.evasion.perturbation_models import PerturbationModels


class GradientProcessing:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import torch

from src.adv.evasion.perturbation_models import PerturbationModels
from secml2.adv.evasion.perturbation_models import PerturbationModels


class Initializer:
Expand Down

0 comments on commit 5f0ee0a

Please sign in to comment.