unexpected labal '38' deepLab error - caffe

I am trying to finetune deepLab network used for Semantic Segmentation on my own data which has pixel-wise labels for 2 classes: 'hands' and background. My ground truth segmentation maps are binary maps with 1 for hands and 0 for background.
I changed deeplab-largeFOV network to have 2 output labels instead of 21 (21 when trained on PASCAL VOC) and tried to run it. It somehow changes my labels from 1 to 38 and then throws following error:
F1101 20:47:22.904304 21648 seg_accuracy_layer.cpp:92] Unexpected label 38. num: 0. row: 3. col: 15
I tried printing values it takes for ground truth from "interp" layer and it seems that for some reason my labels for hands are being converted to 38. Can someone please explain me why it is happening?
I am stuck on it since more than a week and it is really frsutrating now. Any help will be highly appreciated.
Thanks!

Change the accuracy layer from "SegAccuracy" to "Accuracy" and then this error will go away.

Related

I want to resolve the “Error in diag(vcov(object)) : long vectors not supported yet: array.c:2192” error

I have done a multiple regression analysis in lmer.
So I wanted to calculate the confidence interval of the partial regression coefficient using confint(), and when I enter the following code, I get an error "
> confint(H2_FULL, method="Wald")
***Error in diag(vcov(object)) :
long vectors not supported yet: array.c:2192***
" and cannot run it.
Does anyone know how to resolve this error? Please help.
I am a beginner in R. I would appreciate it if you could help me to understand it clearly.
I only need to be able to calculate 95% confidence intervals for the partial regression coefficients of multiple regression analysis(multi-model).
I assume four explanatory variables, which is why I think this error was made.
This error did not occur in the single regression analysis.

Transformer Model Output Nan Values in Pytorch

2021-03-09
I trained my transformer models in pytrorch. In the first few batches, the loss calculation and gradient updates were all performing well. However, the output of the model turned out to be nan values after several iterations. I am confident that there are no flawed data in the dataset. Besides, it's not a classification problem, the labels are float numbers.
2021-03-10
Follow-up:
What an interesting story! When I ran this transformer model with a larger architecture (like 6 encoder layers, 8 heads, etc.). The NAN values disappeared. It seems that the gradient explosion only existed in tiny models.
Solutions:
I searched the Pytorch forum and Stackoverflow and found out the accurate reason for this NAN instance. First, since the NAN loss didn't appear at the very beginning. We can conclude that the model might be well defined. The cause might be the data or the training process. I ran torch.autograd.set_detect_anomaly(True) as told in https://discuss.pytorch.org/t/gradient-value-is-nan/91663/2. It returned that the RuntimeError: Function ‘StdBackward1’ returned nan values in its 0th output.
According to the similar question in https://discuss.pytorch.org/t/gradient-of-standard-deviation-is-nan/14713, I double-checked the output in each layer inside the transformer. Strangely, after dozens of iterations, the positional embedding layer outputted a vector full of zeros. As a result, the LayerNorm that does the normalization job cannot backward the loss well, since it calculated the standard deviations and the standard deviation has no gradient at zero (or you can say it's infinite)! The possible solution is to add x.std(unbiased=False) if you are using pytorch.
This's my encounter with the NAN loss and mse. I hope my experience can give some insights to you when you meet this circumstance!
Relative Questions: Deep-Learning Nan loss reasons
For what it's worth, I had this problem and it turned out that I had forgot to initialize an embedding vector, so it was just whatever torch.empty() happened to come upon (likely a lot of zeros.)

How do I fix an error with dataaspectratio not being finite in Octave?

I'm writing a simple script that iterates some data and plots the result. It was working fine. Then I zoomed in on the plot. After doing that, every time I try to run it I get the error
error: set: "dataaspectratio" must be finite
whether I use plot() or pcolor(). I found from a search that I can check the data aspect ratio with daspect() and the answer is [4 2 1] which looks finite to me. Even if I close and restart this error persists and won't let me plot anything, even a simple thing from the command line. Or a graph comes up with no y axis. How can I fix this?
The full error trying to run my file logistic.m is:
logistic
error: set: "dataaspectratio" must be finite
error: called from
__plt__>__plt2vv__ at line 495 column 10
__plt__>__plt2__ at line 242 column 14
__plt__ at line 107 column 18
plot at line 223 column 10
logistic at line 8 column 1
error: set: "dataaspectratio" must be finite
Here's the full script that I used:
R=linspace(0,4,100);
for j=1:100
r=R(j);
X=linspace(0,1,100);
for i=1:1000
X=r*(X-X.*X);
endfor
plot(R,X);
hold on;
endfor
Just now, after starting Octave again, this problem went away. A while later it came back. All I did was zoom into a plot that I made. The plot window still comes up the first time, but it's just a horizontal line with no axes. After that, the plot window doesn't even come up.

Error in solve.default(res$hessian*n.used,A): 'a' must be a complex matrix

I am using the arima function in R's forecast package and I get the following error:
Error in solve.default(res$hessian*n.used,A): 'a' must be a complex matrix
The time series that I am fitting has very large values numbers e.g. greater than 10 million. Can anyone please provide a solution that might alleviate this error? Would scaling the time series help?

OpenAI gym: How to get pixels in CartPole-v0

I would like to access the raw pixels in the OpenAI gym CartPole-v0 environment without opening a render window. How do I do this?
Example code:
import gym
env = gym.make("CartPole-v0")
env.reset()
img = env.render(mode='rgb_array', close=True) # Returns None
print(img)
img = env.render(mode='rgb_array', close=False)
# Opens annoying window, but gives me the array that I want
print(img.shape)
PS. I am having a hard time finding good documentation for OpenAI gym. Is it just me, or does it simply not exist?
Edit: I don't need to ever open the render video.
I was curious about same so I started looking into the source code and this is what I found.
Open AI uses pyglet for displaying the window and animations.
For showing the animation everything is drawn on to window and then rendered.
And then pyglet stores what is being displayed on to a buffer.
Dummy version of how code is written in open AI
import pyglet
from pyglet.gl import *
import numpy as np
display = pyglet.canvas.get_display()
screen = display.get_screens()
config = screen[0].get_best_config()
pyglet.window.Window(width=500, height=500, display=display, config=config)
# draw what ever you want
#get image from the buffer
buffer = pyglet.image.get_buffer_manager().get_color_buffer()
image_data=buffer.get_image_data()
arr = np.frombuffer(image_data.get_data(),dtype=np.uint8)
print(arr)
print(arr.shape)
output:
[0 0 0 ... 0 0 0]
(1000000,)
so basically every image we get is from buffer of what is being displayed on the window.
So if we don't draw anything on window we get no image so that window is required to get the image.
so you need to find a way such that windows is not displayed but its values are stored in buffer.
I know its not what you wanted but I hope it might lead you to a solution.
I've just gone through half of the gym source code line by line, and I can tell you that 1, the observation space of cartpole is digits to the ai, not pixels. eg, from their cartpole env py file...
Observation:
Type: Box(4)
Num Observation Min Max
0 Cart Position -2.4 2.4
1 Cart Velocity -Inf Inf
2 Pole Angle -0.209 rad (-12 deg) 0.209 rad (12 deg)
3 Pole Angular Velocity -Inf Inf
So, the pixels are for you at this point. And 2, if your goal is to teach the ai on pixels, you will need to render images from your data-in array, then pass them THROUGH the observation space as a pixel array, like Maunish Dave shows. OpenAI's Atari version does this.
If you want a better guide, don't read the OpenAI Docs, read the Stable Baseline docs here: https://stable-baselines.readthedocs.io/
Someone offers an answer here:
https://github.com/openai/gym/issues/374
"The atari and doom environments give pixels in their observations (ie, the return value from step). I don't think any other ones do.
render produces different results on different OSes, so they're not part of any official environment for benchmarking purposes. But if you want to create a new environment where the observation is in pixels, you could implement it by wrapping an existing environment and calling render."
I'm also working on getting raw pixels as well and I'm trying to find a way to see if what has been returned is what I expect it is.
The documentation can be found:
https://gym.openai.com/docs
And a forum for discussing OpenAI:
discuss.openai.com
Although its not very lively.
I have faced the similar problem:
This is how fixed it, in rendering.py file at /gym/envs/classic_control find the following line in the Viewer class:
self.window = pyglet.window.Window(width=width, height=height, display=display)
Change this line to:
self.window = pyglet.window.Window(width=width, height=height, display=display, visible=False)
Hope it helps!!