kcai-data-sampling-fgsm
The adversarial slot of kcai data-sampling: transformations where a model's
response enters the computation. Here the
model is a target — it is not asked to produce anything, only to react. That
is what makes the family adversarial, and the declaring model_role = "target"
is what tells the framework to treat it as such.
This package implements the Fast Gradient Sign Method as a single budgeted step
along the sign of the target model's gradient, and exposes it through the
kcai_data_sampling.transformations entry-point group.
The target model is yours. It arrives at run time through the models:
section of your configuration and is never shipped by this package.
What it ships today
fgsm— one method: one L-infinity step of budgetepsilonalong the sign of the target's gradient.
One method, as an example of the slot rather than a catalogue.
Install
pip install "kcai-data-sampling[fgsm]"
No deep-learning framework is required. This package depends only on the
core contracts — the gradient arrives from your model, so the work is yours
too, and nothing here pulls torch. A configuration driving fgsm may well need
torch in the environment that hosts the target model; that is a property of the
model you bring, not of this package.
How the step works
The batch is normalized to [0, 1] pixel units, the target's gradient is taken
in the same units, and epsilon * sign(grad) is added — so only the sign of
the gradient participates, not its magnitude. The result is clipped back into
range and restored to the batch's dtype.
Three declarations follow from that, and the framework enforces each:
clips = True— a signed step can push a pixel past the selection's value range, so the output is clipped back rather than refused.reversible = False— the step is lossy. The original pixels are not recoverable from the output, so the row records that it is not invertible.- Deterministic — no randomness is drawn, so the recorded seed is
None. The same input and the sameepsilonalways give the same output.
epsilon is the adversarial budget, strictly positive, and sweepable, so a run
can walk a whole budget curve.
The annotation does not move
An attack moves the model's prediction, not the truth. The annotation belongs to the source row, travels with it, and is never touched here — this package has no notion of an annotation at all, only of pixels.
That is what makes an adversarial sample meaningful: if the annotation had moved along with the pixels, the pair would prove nothing. An annotation that changed under the attack, or a target model whose response was ignored, would both mean the measurement was not an attack at all.
Example
The models and operations sections of a job configuration, with a target
model supplied as your own source:
models:
yolo:
type: python
path: adapters/yolo_target.py
export: YoloTarget
weights: yolov8n.pt
params: { conf: 0.25 }
operations:
transformations:
- name: fgsm
type: fgsm
target_model: yolo
epsilon:
range: [0.01, 0.05]
step: 0.01
The transformation names its model with target_model: yolo. Only grad is
used from it, and its output is checked for shape and finiteness before the step,
so a misbehaving adapter fails loudly rather than corrupting the batch.
A target model is recognised by a non-empty name plus a grad method, and
conformance is checked against the target role the transformation declares.
Metadata
Release files for kcai-data-sampling-fgsm 0.8.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| kcai_data_sampling_fgsm-0.8.1.tar.gz | 8.6 kB | Without provenance | Details for kcai_data_sampling_fgsm-0.8.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kcai_data_sampling_fgsm-0.8.1-py3-none-any.whl | Python 3 | none | any | Details for kcai_data_sampling_fgsm-0.8.1-py3-none-any.whl |
Total release size: 17.8 kB
Release files / kcai_data_sampling_fgsm-0.8.1.tar.gz
| Download URL | kcai_data_sampling_fgsm-0.8.1.tar.gz |
|---|---|
| Size | 8.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
022d4f0195da0266f7a97447b7174241546d50074563287ff316f1ae4a86394c
|
|
BLAKE2b-256 checksum How to use checksums |
3c2850577018b1f66042802fcbfeb06a2efe8227ff7d99c4ea3468459ad23f64
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.8.17
|
Release files / kcai_data_sampling_fgsm-0.8.1-py3-none-any.whl
| Download URL | kcai_data_sampling_fgsm-0.8.1-py3-none-any.whl |
|---|---|
| Size | 9.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
26e6f25c3f0ae391f0b5b8b1f9f57052dde555de6630534ec6303ef8bca7c024
|
|
BLAKE2b-256 checksum How to use checksums |
9dcfd1c3b05f110064d34753b5925162b9b55caf03e67a6a7d1ece8401650dbd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.8.17
|
Security for kcai-data-sampling-fgsm 0.8.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.