Answers.Body: <p>It definitely is. If you check the <a href="https://github.com/hanzhanggit/StackGAN-Pytorch/blob/master/code/model.py" rel="nofollow noreferrer">code</a> (line 145) you'll see that in the forward definition of the Stage1 Generator they do:</p>
  <pre><code>class STAGE1_G(nn.Module):
      def __init__(self):
  ...
      def forward(self, text_embedding, noise):
      c_code, mu, logvar = self.ca_net(text_embedding)
      z_c_code = torch.cat((noise, c_code), 1)
      h_code = self.fc(z_c_code)
  
      h_code = h_code.view(-1, self.gf_dim, 4, 4)
  </code></pre>
  <p>Where self.gf_dim is a parameter defined in the configuration file of the gan (most likely number of feature maps, but check cause they didn't write documentation about the config settings)</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-09-17T07:21:38.963Z
Answers.LastActivityDate: 2021-09-17T07:21:38.963Z
Answers.UserDisplayName: Edoardo Guerriero
Body: <p>Consider the following paragraph from <code>A.1 MULTI-MNIST AND CLEVR</code> of <code>A IMPLEMENTATION DETAILS</code> from the research paper titled <a href="https://arxiv.org/pdf/1901.00686.pdf" rel="nofollow noreferrer">GENERATING MULTIPLE OBJECTS AT SPATIALLY DISTINCT LOCATIONS</a> by <em>Tobias Hinz et al.</em></p>
  <blockquote>
  <p>In the global pathway of the generator we first obtain the layout
  encoding. For this we create a tensor of shape (10, 16, 16) (CLEVR:
  (13, 16, 16)) that contains the one-hot labels at the location of the
  bounding boxes and is zero everywhere else. We then apply three
  convolutional layers, each followed by batch normalization and a leaky
  ReLU activation. We reshape the output to shape (1, 64) and
  concatenate it with the noise tensor of shape (1, 100) (sampled from a
  random normal distribution) to form a tensor of shape (1, 164). <strong>This
  tensor is then fed into a dense layer, followed by batch normalization
  and a ReLU activation and the output is reshaped to (−1, 4, 4). We
  then apply two upsampling blocks to obtain a tensor of shape (−1, 16,
  16).</strong></p>
  </blockquote>
  <p>The paragraph is saying that a tensor of shape (1, 164) is reshaped to (-1, 4, 4). What is  the reason behind using negative number -1? Is it <a href="https://ai.stackexchange.com/a/29932/18758">representing axis</a>? Can't we represent it with <span class="math-container">$a \times x \times y$</span>, where <span class="math-container">$a, x, y$</span>  are natural number s and dimensions of the tensor?</p>
  <p><span class="math-container">$\dfrac{164}{4 \times 4}$</span> is not a natural number, so what is the shape of the reshaped tensor using only the natural numbers?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-09-17T13:18:54.597Z
Comments.Text: This seems to be just a programming question, so I will close it, unless you clarify how this is not just a programming question.
Comments.UserDisplayName: nbro
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-09-17T13:20:24.743Z
Comments.Text: @nbro my primary question is what -1 represents: dimension or axis.
Comments.UserDisplayName: hanugm
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-09-17T13:25:56.563Z
Comments.Text: In my view, this is still a programming question, because -1 may not exist in all libraries, and its meaning may depend on the specific library. The other linked question that I answered could also be considered a programming question for the same reason. I would avoid asking these questions here, if you don't want them to be closed. I will leave this open for now, but to me this seems to be off-topic.
Comments.UserDisplayName: nbro
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-09-17T13:31:23.270Z
Comments.Text: @nbro But, authors started using them in their research papers. What would you say about this? i mean, what is your opinion on it?
Comments.UserDisplayName: hanugm
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-09-17T13:35:06.400Z
Comments.Text: In Tensorflow, -1 means to calculate automatically. Only one dimension can be -1
Comments.UserDisplayName: Criticize SE actions means ban
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-09-17T13:35:48.703Z
Comments.Text: The 164 tensor is not reshaped to (-1,4,4). It is fed to a dense layer and the output of the dense layer is reshaped to (-1,4,4)
Comments.UserDisplayName: Criticize SE actions means ban
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-09-17T15:32:07.197Z
Comments.Text: @hanugm I didn't read the paper, but they are probably assuming that the user is familiar with the most common libraries for deep learning, i.e. TensorFlow, Keras, and PyTorch, where this notation/implementation is used (not sure in PyTorch, as I've not used it for a long time, but it should be the same). I've just quickly checked and they mention PyTorch or a link to some implementation there, so they are probably using this notation because they assume people that will read this paper are or should be familiar with PyTorch.
Comments.UserDisplayName: nbro
Tags: <implementation><notation><tensor>
Title: Why using negative integers (as dimensions?) in tensor shapes rather than natural numbers?
UserDisplayName: hanugm
ThreadText: # Why using negative integers (as dimensions?) in tensor shapes rather than natural numbers?
  
  (Asked by: username_0 on 2021-09-17)
  
  Consider the following paragraph from `A.1 MULTI-MNIST AND CLEVR` of `A IMPLEMENTATION DETAILS` from the research paper titled [GENERATING MULTIPLE OBJECTS AT SPATIALLY DISTINCT LOCATIONS](https://arxiv.org/pdf/1901.00686.pdf) by *Tobias Hinz et al.*
  
  > In the global pathway of the generator we first obtain the layout
  > encoding. For this we create a tensor of shape (10, 16, 16) (CLEVR:
  > (13, 16, 16)) that contains the one-hot labels at the location of the
  > bounding boxes and is zero everywhere else. We then apply three
  > convolutional layers, each followed by batch normalization and a leaky
  > ReLU activation. We reshape the output to shape (1, 64) and
  > concatenate it with the noise tensor of shape (1, 100) (sampled from a
  > random normal distribution) to form a tensor of shape (1, 164). **This
  > tensor is then fed into a dense layer, followed by batch normalization
  > and a ReLU activation and the output is reshaped to (−1, 4, 4). We
  > then apply two upsampling blocks to obtain a tensor of shape (−1, 16,
  > 16).**
  
  The paragraph is saying that a tensor of shape (1, 164) is reshaped to (-1, 4, 4). What is the reason behind using negative number -1? Is it [representing axis](https://ai.stackexchange.com/a/29932/18758)? Can't we represent it with $a \times x \times y$, where $a, x, y$ are natural number s and dimensions of the tensor?
  
  $\dfrac{164}{4 \times 4}$ is not a natural number, so what is the shape of the reshaped tensor using only the natural numbers?
  
  **Tags:** implementation, notation, tensor
  > **Comments:**
  > **username_1**: This seems to be just a programming question, so I will close it, unless you clarify how this is not just a programming question.  
  > **username_0**: @nbro my primary question is what -1 represents: dimension or axis.  
  > **username_1**: In my view, this is still a programming question, because -1 may not exist in all libraries, and its meaning may depend on the specific library. The other linked question that I answered could also be considered a programming question for the same reason. I would avoid asking these questions here, if you don't want them to be closed. I will leave this open for now, but to me this seems to be off-topic.  
  > **username_0**: @nbro But, authors started using them in their research papers. What would you say about this? i mean, what is your opinion on it?  
  > **username_2**: In Tensorflow, -1 means to calculate automatically. Only one dimension can be -1  
  > **username_2**: The 164 tensor is not reshaped to (-1,4,4). It is fed to a dense layer and the output of the dense layer is reshaped to (-1,4,4)  
  > **username_1**: @hanugm I didn't read the paper, but they are probably assuming that the user is familiar with the most common libraries for deep learning, i.e. TensorFlow, Keras, and PyTorch, where this notation/implementation is used (not sure in PyTorch, as I've not used it for a long time, but it should be the same). I've just quickly checked and they mention PyTorch or a link to some implementation there, so they are probably using this notation because they assume people that will read this paper are or should be familiar with PyTorch.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_3 on 2021-09-17. Score: 0
  
  It definitely is. If you check the code (line 145) you'll see that in the forward definition of the Stage1 Generator they do:
  class STAGE1_G(nn.Module):
      def __init__(self):
  ...
      def forward(self, text_embedding, noise):
      c_code, mu, logvar = self.ca_net(text_embedding)
      z_c_code = torch.cat((noise, c_code), 1)
      h_code = self.fc(z_c_code)
  
      h_code = h_code.view(-1, self.gf_dim, 4, 4)
  
  Where self.gf_dim is a parameter defined in the configuration file of the gan (most likely number of feature maps, but check cause they didn't write documentation about the config settings)
  
  
  ---
  
  