Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class predicted always 0 #14

Open
Sypotu opened this issue Oct 2, 2017 · 10 comments
Open

Class predicted always 0 #14

Sypotu opened this issue Oct 2, 2017 · 10 comments

Comments

@Sypotu
Copy link

Sypotu commented Oct 2, 2017

Hi,

I am training the network initialized with alexnet_imagenet.npy using the rendered views furnished by @WeiTang114 (https://drive.google.com/open?id=0B4v2jR3WsindMUE3N2xiLVpyLW8).
The only thing I have changed is to reduce the batch size from 16 to 8 because my GPU doesn't have enough memory.

But quite quickly (after 300-400 steps) the network get stuck classifying all the inputs as class 0. (accuracy corresponding to random guess)
Can this be due to the reduction of the batch size or there is another reason?

Thank you for your help!

@rlczddl
Copy link

rlczddl commented Oct 26, 2017

I also set batch_size to 8 because of my pc,and I also meet your problem.Have you find the cause?

@rlczddl
Copy link

rlczddl commented Oct 26, 2017

set batchsize to16, also.

@rlczddl
Copy link

rlczddl commented Nov 1, 2017

not the reason ofbatchsize,because i have trained on another better pc,and prediction is also 0.

@rlczddl
Copy link

rlczddl commented Nov 1, 2017

maybe the reason of his fc8 using relu.

@Sypotu
Copy link
Author

Sypotu commented Nov 1, 2017

Yes i have removed the relu after fc8 and it's working fine now

@rlczddl
Copy link

rlczddl commented Nov 1, 2017

have you made other changes?i remove relu layer after fc8,and set substract_mean is true because i use another dataset,but prediction are always same(not only 0,but alos other numbers)

@Sypotu
Copy link
Author

Sypotu commented Nov 1, 2017

Are they the same from the first step or do they slowly converge to always same values?

@rlczddl
Copy link

rlczddl commented Nov 1, 2017

image
image
image

(In first picture,the first list [122,18,69,100,38...] is the real label of validation data,and the second line [116,116,116,116...] is the predictions on validation data.The predictions on test data is also like this )
This is my training process,as you can see,the predictions on validation data are always same,but they are different every time of validate.

@Sypotu
Copy link
Author

Sypotu commented Nov 1, 2017

How did you change the network to remove the relu ?
I added this :

def _fc_norelu(name, in_, outsize, reuse=False):
    with tf.variable_scope(name, reuse=reuse) as scope:
        # Move everything into depth so we can perform a single matrix multiply.
        
        insize = in_.get_shape().as_list()[-1]
        weights = _variable_with_weight_decay('weights', shape=[insize, outsize], wd=0.004)
        biases = _variable_on_cpu('biases', [outsize], tf.constant_initializer(0.0))
        fc = tf.matmul(in_, weights) + biases

        _activation_summary(fc)

    print name, fc.get_shape().as_list()
    return fc

And I have replaced fc8 = _fc("fc8", fc7, n_classes) by fc8 = _fc_norelu('fc8', fc7, n_classes)

@rlczddl
Copy link

rlczddl commented Nov 1, 2017

image

I just modify the fc8 in inference_multiview function of model.py,it should work likely yours.I will try yours.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants