Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
1. Adversarial Attacks (
Attacks.py)gradient_map: Replaced complex backpropagation options (guided, relu) with a simpler implementation utilizing a newcompute_gradientshelper function.gradient_ascent: Significantly altered the signature. It now maximizes atarget_classon a single input image rather than maximizing a specifictarget_neuronacross a batch of data.fgsm_attack: Modified to return a list of tensors rather than a stacked tensor array (torch.stack).visualize_adversarial_examples,log_metrics,saliency_map, and theConfigclass.2. Particle Logic (
BirdParticle.py)BirdParticleinitialization no longer requires PyTorch-specific arguments likemodel,input_data,target_class, ordevice. It now only tracks its own position, velocity, and clamping boundaries.fitness()method was replaced byevaluate(costFunc, model), delegating the evaluation logic to an external cost function rather than calculating softmax probabilities internally.update_velocitynow takes a simple list/tensor for the global best position (pos_best_g) instead of recalculating based on the model state.minclampandmaxclampparameters instead ofclip_value_position.3. Swarm Logic (
Swarm.py)ParticleSwarmwas renamed toPSO.BirdParticle, the swarm initialization was heavily stripped down. It now acceptsstarting_positionsand an explicitcost_funcrather than hardcoding image classification concepts likestarting_classandtarget_class.run()withtqdmprogress bars) and internal logging (setup_logging,log_progress) were removed. The swarm now relies on astep()function, giving the user control over the training loop.get_history()method that outputs the swarm's positional history as apandas.DataFrame, and asave_history()method to export it to a CSV.getBest()andgetPoints()were updated to returntorch.Tensorobjects rather than unhooked NumPy arrays.reduce_excess_perturbationsmethod was completely removed.4. Unit Tests (
tests/)test_adversarial_attacks.py: Updated assertions to account for the attacks returning lists instead of single multi-dimensional tensors, and updatedtest_gradient_ascentto passtarget_classinstead oftarget_neuron.test_bird_particle.py: Removed the PyTorch model fixture dependency, asBirdParticleno longer requires it for initialization. Updated parameter names to matchminclampandmaxclamp.test_pso_optimization.py: * Updated references fromParticleSwarmtoPSO.dummy_cost_funcfixture to fulfill the newPSOinitialization requirements.torch.Tensorinstead ofnp.ndarray.history.csvfile rather than a standard.logfile.