class_docstr: Convolutional Layers to estimate NMF Activations from Classifier Representations, optimized for log-spectra.
  
  Arguments
  ---------
  dim: int
      Dimension of the hidden representations (input to the classifier).
  K : int
      Number of NMF components (or equivalently number of neurons at the output per timestep)
  num_classes : int
      Number of possible classes.
  use_adapter : bool
      `True` if you wish to learn an adapter for the latent representations.
  adapter_reduce_dim: bool
      `True` if the adapter should compress the latent representations.
  
  Example
  -------
  >>> inp = torch.randn(1, 256, 26, 32)
  >>> psi = PsiOptimized(dim=256, K=100, use_adapter=False, adapter_reduce_dim=False)
  >>> h, inp_ad= psi(inp)
  >>> print(h.shape, inp_ad.shape)
  torch.Size([1, 1, 417, 100]) torch.Size([1, 256, 26, 32])
class_docstr_tok: ["Convolutional","Layers","to","estimate","NMF","Activations","from","Classifier","Representations",",","optimized","for","log-spectra",".","Arguments","--","--","--","--","-","dim",":","int","Dimension","of","the","hidden","representations","(","input","to","the","classifier",")",".","K",":","int","Number","of","NMF","components","(","or","equivalently","number","of","neurons","at","the","output","per","timestep",")","num_classes",":","int","Number","of","possible","classes",".","use_adapter",":","bool","`","True","`","if","you","wish","to","learn","an","adapter","for","the","latent","representations",".","adapter_reduce_dim",":","bool","`","True","`","if","the","adapter","should","compress","the","latent","representations",".","Example","--","--","--","-",">",">",">","inp","=","torch.randn","(","1",",","256",",","26",",","32",")",">",">",">","psi","=","PsiOptimized","(","dim=256",",","K=100",",","use_adapter=False",",","adapter_reduce_dim=False",")",">",">",">","h",",","inp_ad=","psi","(","inp",")",">",">",">","print","(","h.shape",",","inp_ad.shape",")","torch.Size","(","[","1",",","1",",","417",",","100","]",")","torch.Size","(","[","1",",","256",",","26",",","32","]",")"]
docstr: Computes NMF activations from hidden state.
docstr_tok: ["Computes","NMF","activations","from","hidden","state","."]
code: def __init__(
      self,
      dim=128,
      K=100,
      numclasses=50,
      use_adapter=False,
      adapter_reduce_dim=True,
  ):
      """
      Computes NMF activations from hidden state.
      """
      super().__init__()
  
      self.use_adapter = use_adapter
      self.adapter_reduce_dim = adapter_reduce_dim
      if use_adapter:
          self.adapter = ResBlockAudio(dim)
  
          if adapter_reduce_dim:
              self.down = nn.Conv2d(dim, dim, 4, (2, 2), 1)
              self.up = nn.ConvTranspose2d(dim, dim, 4, (2, 2), 1)
  
      self.decoder = nn.Sequential(
          nn.ConvTranspose2d(dim, dim, 3, (2, 2), 1),
          nn.ReLU(True),
          nn.BatchNorm2d(dim),
          nn.ConvTranspose2d(dim, dim, 4, (2, 2), 1),
          nn.ReLU(),
          nn.BatchNorm2d(dim),
          nn.ConvTranspose2d(dim, dim, 4, (2, 2), 1),
          nn.ReLU(),
          nn.BatchNorm2d(dim),
          nn.ConvTranspose2d(dim, dim, 4, (2, 2), 1),
          nn.ReLU(),
          nn.BatchNorm2d(dim),
          nn.ConvTranspose2d(dim, 1, 12, 1, 1),
          nn.ReLU(),
          nn.Linear(513, K),
          nn.ReLU(),
      )
      self.apply(weights_init)
  
imports: import torch.nn
  import torch.nn.functional
  import torch
  from speechbrain.lobes.models.PIQ import ResBlockAudio
label_desc: Use image node_id 1 to create a new PsiOptimized object from inherited base classes: nn with example: obj = PsiOptimized(dim, K, numclasses, use_adapter, adapter_reduce_dim)