Skip to content

sgmath12/Snipets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pytorch Code Snipets

dataset.py

  • This code made it easy to retrieve the data set before entering the dataloader of the pytorch model.

Feature Extractor (hook.py)

  • It is a code that extracts the intermediate feature of the pytorch model.
  • You can select the type of layer you want. For instance, If you want to extract the intermediate feature after the relu activation, modify as follows.
if  isinstance(layer,nn.ReLU)  :
    layer.register_forward_hook(self.get_activation(idx))
    self.names[idx] = layer
    idx += 1

dod_line_subfigure.py

  • It's a code for drawing figures easily using matplotlib. You will draw a dot-line as shown in the following picture.
  • You can enter data in the text file, and for more information on how to operate, see the code line of Dod_data class and directory /data, then you can understand how to use.
  • Enter the data and run it as follows.
python dod_line_subgraph.py
  • If --common_legend True, then it will creates subgraphs with common legned as follows.

prob_test

  • If --common_legend False, then it will creates subgraph wihh normal legend as follows.

      

About

Code Senipets

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages