original_docstring: generate all parameters: 5 -> 6000 mapping
docstring: generate all parameters: 5 -> 6000 mapping
docstring_tokens: generate all parameters : 5 - > 6000 mapping
code: def forward(self, x, mc, get_dyn_feat=False):  # add modality code as additional input
          # adapted from https://github.com/jianpengz/DoDNet/blob/main/a_DynConv/unet3D_DynConv882.py
  
          N, _, H, W = x.size()
          x = x.reshape(1, -1, H, W)  # 1 x N*15 x 128 x 128
  
          params = self.controller(mc.unsqueeze(-1).unsqueeze(-1).float())  # 1 x 48*15+48 x 1 x 1
          params.squeeze_(-1).squeeze_(-1)  # 1 x 48*15+48
          # print(params.size())  # N x 768
          weight_nums, bias_nums = [], []
          weight_nums.append(15 * 48)
          bias_nums.append(48)
          sw, sb = parse_dynamic_params(params, weight_nums, bias_nums)
          sw = sw.reshape(N, 48, 15).unsqueeze(-1).unsqueeze(-1)
          sb = sb.reshape(N, 48)
  
          """generate all parameters: 5 -> 6000 mapping"""
          # N, _, H, W = x.size()
          # x = x.reshape(1, -1, H, W)
          # out = my_first_conv(x, weights, biases, N)
          # out = out.reshape(-1, 48, out.size()[-2], out.size()[-1])
  
          w, b = self.firstconv.weight.clone().unsqueeze(0), self.firstconv.bias.clone()  # 1 x 48 x 15 x 3 x 3
          # This function is differentiable, so gradients will flow back from the result of this operation to input.
          # To create a tensor without an autograd relationship to input see detach()
  
          # check if both scalars and kernels are updated!
          # print('======================================')
          # print(self.firstconv.weight[0, 0, :, :], self.firstconv.bias[0])
          # print(sw[0, :3, :3, 0, 0])
  
          w = w * sw
          b = b * sb
  
          # print(sw.size(), w.size())
          # print(w.size(), b.size())
  
          w = w.reshape(-1, 15, 3, 3)
          b = b.reshape(-1)
  
          out = dynamic_head(x, w, b, N)
          out = out.reshape(-1, 48, out.size()[-2], out.size()[-1])
  
          # dynamic filter place! #
          if get_dyn_feat:
              dyn_feat = out
  
          # regular network
          skip_connections = []
          for i in range(len(self.down_blocks)):
              out = self.denseBlocksDown[i](out)
              skip_connections.append(out)
              out = self.transDownBlocks[i](out)
  
          # print(out)
          out = self.bottleneck(out)
  
          # BOTTLENECK PLACE! # deprecated
          # print('===============')
          # if get_dyn_feat:
          #     dyn_feat = out
          # print('===============')
  
          for i in range(len(self.up_blocks)):
              skip = skip_connections.pop()
              out = self.transUpBlocks[i](out, skip)
              out = self.denseBlocksUp[i](out)
  
          out = self.finalConv(out)
          out = self.tanh(out)
          # out = self.softmax(out)
          # print(out.size())
          
          if get_dyn_feat:
              return dyn_feat, out
          return out
code_tokens: def forward ( self , x , mc , get_dyn_feat = False ) : N , _ , H , W = x . size ( ) x = x . reshape ( 1 , - 1 , H , W ) params = self . controller ( mc . unsqueeze ( - 1 ) . unsqueeze ( - 1 ) . float ( ) ) params . squeeze_ ( - 1 ) . squeeze_ ( - 1 ) weight_nums , bias_nums = [ ] , [ ] weight_nums . append ( 15 * 48 ) bias_nums . append ( 48 ) sw , sb = parse_dynamic_params ( params , weight_nums , bias_nums ) sw = sw . reshape ( N , 48 , 15 ) . unsqueeze ( - 1 ) . unsqueeze ( - 1 ) sb = sb . reshape ( N , 48 ) w , b = self . firstconv . weight . clone ( ) . unsqueeze ( 0 ) , self . firstconv . bias . clone ( ) w = w * sw b = b * sb w = w . reshape ( - 1 , 15 , 3 , 3 ) b = b . reshape ( - 1 ) out = dynamic_head ( x , w , b , N ) out = out . reshape ( - 1 , 48 , out . size ( ) [ - 2 ] , out . size ( ) [ - 1 ] ) if get_dyn_feat : dyn_feat = out skip_connections = [ ] for i in range ( len ( self . down_blocks ) ) : out = self . denseBlocksDown [ i ] ( out ) skip_connections . append ( out ) out = self . transDownBlocks [ i ] ( out ) out = self . bottleneck ( out ) for i in range ( len ( self . up_blocks ) ) : skip = skip_connections . pop ( ) out = self . transUpBlocks [ i ] ( out , skip ) out = self . denseBlocksUp [ i ] ( out ) out = self . finalConv ( out ) out = self . tanh ( out ) if get_dyn_feat : return dyn_feat , out return out
short_docstring: generate all parameters: 5 -> 6000 mapping
short_docstring_tokens: generate all parameters : 5 - > 6000 mapping
comment: # add modality code as additional input$SEP$# adapted from https://github.com/jianpengz/DoDNet/blob/main/a_DynConv/unet3D_DynConv882.py$SEP$# 1 x N*15 x 128 x 128$SEP$# 1 x 48*15+48 x 1 x 1$SEP$# 1 x 48*15+48$SEP$# print(params.size())  # N x 768$SEP$"""generate all parameters: 5 -> 6000 mapping"""$SEP$# N, _, H, W = x.size()$SEP$# x = x.reshape(1, -1, H, W)$SEP$# out = my_first_conv(x, weights, biases, N)$SEP$# out = out.reshape(-1, 48, out.size()[-2], out.size()[-1])$SEP$# 1 x 48 x 15 x 3 x 3$SEP$# This function is differentiable, so gradients will flow back from the result of this operation to input.$SEP$# To create a tensor without an autograd relationship to input see detach()$SEP$# check if both scalars and kernels are updated!$SEP$# print('======================================')$SEP$# print(self.firstconv.weight[0, 0, :, :], self.firstconv.bias[0])$SEP$# print(sw[0, :3, :3, 0, 0])$SEP$# print(sw.size(), w.size())$SEP$# print(w.size(), b.size())$SEP$# dynamic filter place! #$SEP$# regular network$SEP$# print(out)$SEP$# BOTTLENECK PLACE! # deprecated$SEP$# print('===============')$SEP$# if get_dyn_feat:$SEP$#     dyn_feat = out$SEP$# print('===============')$SEP$# out = self.softmax(out)$SEP$# print(out.size())