Coder Social home page Coder Social logo

t-sne's Introduction

FIRST BETA OF MAGICAL t-SNE plotter

Screenshot Screenshot

thanks to:

def eval_plot_source_target(model: nn.Module,
                            source_loader: Iterable,
                            target_loader: Iterable,
                            class_mapping: Dict[str,int],
                            device: str ='cpu',callback_fn=None, colormap:Dict[int,Tuple[int,int,int]] = None) -> None:
  • Model : Almost any torch end-to-end model. Requires the classification layer to be placed on the topmost level in a nn.Sequential module. Example of valid model
  Sequential(
  (0): Extractor(
    (model): Sequential(
      (0): Conv2d(3, 64, kernel_size=(7, 7), stride=(2, 2), padding=(3, 3), bias=False)
      (1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
      (2): ReLU(inplace=True)
      (3): MaxPool2d(kernel_size=3, stride=2, padding=1, dilation=1, ceil_mode=False)
      (4): Sequential(
        (0): BasicBlock(
          (conv1): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (relu): ReLU(inplace=True)
          (conv2): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (bn2): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
        )
      )
      (5): AdaptiveAvgPool2d(output_size=(1, 1))
    )
  )
  (1): Classifier(
    (identity): Identity()
    (fc): Linear(in_features=512, out_features=31, bias=True)
  )
)

Example of invalid model

  Sequential(
  (0): Extractor(
    (model): Sequential(
      (0): Conv2d(3, 64, kernel_size=(7, 7), stride=(2, 2), padding=(3, 3), bias=False)
      (1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
      (2): ReLU(inplace=True)
      (3): MaxPool2d(kernel_size=3, stride=2, padding=1, dilation=1, ceil_mode=False)
      (4): Sequential(
        (0): BasicBlock(
          (conv1): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
          (relu): ReLU(inplace=True)
          (conv2): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
          (bn2): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
        )
      )
      (4): AdaptiveAvgPool2d(output_size=(1, 1))
      (5): Classifier(
        (identity): Identity()
        (fc): Linear(in_features=512, out_features=31, bias=True)
      ) 
    )
  )

)
  • source_loader : Source dataloader. Expects a simple loader of which each element is Tuple(input,output) and input of a shape [batch_size,any]. output should be [batch_size,]
  • target_loader : Target dataloader. Expects a simple loader of which each element is Tuple(input,output) and input of a shape [batch_size,any]. output should be [batch_size,]
  • class_mapping : a Dictionary that contains {'back_pack':0,'purse':1...} for each string that represents the class, it's corresponding int in the dataloader
  • device : where to execute the code. Default on cpu
  • callback_fn: REQUIRED! a function to map the output of your model to a standard [batch_size,] where each item correspond to the prediction for that sample. Example of function that maps a non-argmaxed [batch_size,num_classes]result to a argmaxed [batch_size,]result
def callback_sample(input:Tensor) -> Tensor:
    output = torch.argmax(input,axis=1)
    return output
  • colormap : dictionary of Dict[int,Tuple[int,int,int]] where for each int that represent each class is provided a HEX color. Optional. If not given a perfect rainbow will be generated

t-sne's People

Contributors

bigemperor26 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.