Answers.Body: <p>I've seen this too many times - it's not a problem with your network, it's a problem with matplotlib and how it displays the image. You are probably trying to display a float with range <span class="math-container">$&lt;0, 255&gt;$</span>. When matplotlib sees <code>float</code> type as input, it assumes a range of <span class="math-container">$&lt;0, 1&gt;$</span>, and thresholds everything outside of that range, and the results you can see.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-06-06T13:37:18.833Z
Answers.Text: Before printing, I do `y = np.clip(y, 0, 255)` and `assert y.dtype == np.uint8, 'Must be uint8'`, so these pixels correspond to [0, 0, 0] to [255, 255, 255] where 0/255 are sometimes interchanged to produce yellow/cian etc.
Answers.UserDisplayName: GRS
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-06-06T14:15:37.487Z
Answers.Text: Mind sharing the full code?
Answers.UserDisplayName: Lugi
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-06-06T15:46:28.987Z
Answers.Text: Unfortunately I can't as it would turn into a debugging exercise. I thought it's a common problem that has a known reason for happening. I guess the issue is somewhere in the code. I'm partially afraid that I'm stuck in local minima, but I doubt it.
Answers.UserDisplayName: GRS
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-06-06T23:14:15.837Z
Answers.Text: Trust me, I'll spot your mistake in under 60 second. There's no way a network-related issue results in something like this. It's something with how you process the data.
Answers.UserDisplayName: Lugi
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-06-06T23:53:16.140Z
Answers.Text: Here is the network -> https://github.com/skiler07/mst-tf/blob/master/trainer/MST.py I am implementing a paper. The preprocessing is quite complex. If you wish to reproduce, you can clone master and try running locally.
Answers.UserDisplayName: GRS
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-06-06T13:27:37.757Z
Answers.LastActivityDate: 2019-06-06T13:27:37.757Z
Answers.UserDisplayName: Lugi
Body: <p>I'm building a CNN decoder, which mirrors (in reverse) the VGG network structure from Conv-4-1 layer. </p>
  
  <p>The net seems to be working fine, however, the output looks broken. Please note that the colour distortion is fine, it's the the [255/0 RGB pixels] e.g. green that I'm worrying about.</p>
  
  <p>I tried to overfit a single image, but even then I get these hot pixels. Does anyone know why they appear?</p>
  
  <p><a href="https://i.sstatic.net/akPst.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/akPst.jpg" alt="enter image description here"></a></p>
  
  <p>My net:</p>
  
  <pre><code>    activation = 'elu'
  
      input_ = Input((None, None, 512))
      x = Conv2D(filters=256, kernel_size=self.kernel_size, padding='same', bias_initializer='zeros', activation=activation)(input_)
  
      x = UpSampling2D()(x)
      for _ in range(3):
          x = Conv2D(filters=256, kernel_size=self.kernel_size, padding='same', activation=activation)(x)
      x = Conv2D(filters=128, kernel_size=self.kernel_size, padding='same', activation=activation)(x)
  
      x = UpSampling2D()(x)
      x = Conv2D(filters=128, kernel_size=self.kernel_size, padding='same', activation=activation)(x)
      x = Conv2D(filters=64, kernel_size=self.kernel_size, padding='same', activation=activation)(x)
  
      x = UpSampling2D()(x)
      x = Conv2D(filters=64, kernel_size=self.kernel_size, padding='same', activation=activation)(x)
      x = Conv2D(filters=3, kernel_size=self.kernel_size, padding='same')(x)
  
      model = Model(inputs=input_, outputs=x)
  </code></pre>
  
Tags: <convolutional-neural-networks><computer-vision>
Title: What is wrong with this CNN network, why are there hot pixels?
UserDisplayName: GRS
ThreadText: # What is wrong with this CNN network, why are there hot pixels?
  
  (Asked by: username_0 on 2019-06-06)
  
  I'm building a CNN decoder, which mirrors (in reverse) the VGG network structure from Conv-4-1 layer.
  
  The net seems to be working fine, however, the output looks broken. Please note that the colour distortion is fine, it's the the [255/0 RGB pixels] e.g. green that I'm worrying about.
  
  I tried to overfit a single image, but even then I get these hot pixels. Does anyone know why they appear?
  
  [![enter image description here](https://i.sstatic.net/akPst.jpg)](https://i.sstatic.net/akPst.jpg)
  
  My net:
  
  ```
      activation = 'elu'
  
      input_ = Input((None, None, 512))
      x = Conv2D(filters=256, kernel_size=self.kernel_size, padding='same', bias_initializer='zeros', activation=activation)(input_)
  
      x = UpSampling2D()(x)
      for _ in range(3):
          x = Conv2D(filters=256, kernel_size=self.kernel_size, padding='same', activation=activation)(x)
      x = Conv2D(filters=128, kernel_size=self.kernel_size, padding='same', activation=activation)(x)
  
      x = UpSampling2D()(x)
      x = Conv2D(filters=128, kernel_size=self.kernel_size, padding='same', activation=activation)(x)
      x = Conv2D(filters=64, kernel_size=self.kernel_size, padding='same', activation=activation)(x)
  
      x = UpSampling2D()(x)
      x = Conv2D(filters=64, kernel_size=self.kernel_size, padding='same', activation=activation)(x)
      x = Conv2D(filters=3, kernel_size=self.kernel_size, padding='same')(x)
  
      model = Model(inputs=input_, outputs=x)
  
  ```
  
  **Tags:** convolutional-neural-networks, computer-vision
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-06-06. Score: 3
  
  I've seen this too many times - it's not a problem with your network, it's a problem with matplotlib and how it displays the image. You are probably trying to display a float with range $<0, 255>$. When matplotlib sees `float` type as input, it assumes a range of $<0, 1>$, and thresholds everything outside of that range, and the results you can see.
  
  > **Comments:**
  > **username_0**: Before printing, I do `y = np.clip(y, 0, 255)` and `assert y.dtype == np.uint8, 'Must be uint8'`, so these pixels correspond to [0, 0, 0] to [255, 255, 255] where 0/255 are sometimes interchanged to produce yellow/cian etc.  
  > **username_1**: Mind sharing the full code?  
  > **username_0**: Unfortunately I can't as it would turn into a debugging exercise. I thought it's a common problem that has a known reason for happening. I guess the issue is somewhere in the code. I'm partially afraid that I'm stuck in local minima, but I doubt it.  
  > **username_1**: Trust me, I'll spot your mistake in under 60 second. There's no way a network-related issue results in something like this. It's something with how you process the data.  
  > **username_0**: Here is the network -> https://github.com/skiler07/mst-tf/blob/master/trainer/MST.py I am implementing a paper. The preprocessing is quite complex. If you wish to reproduce, you can clone master and try running locally.  
  
  ---
  
  