wenxinxu/resnet-in-tensorflow

I don't understand why we will use random lable for training. Someone help me, thank you.

EricKani opened this issue · 8 comments

TRAIN_RANDOM_LABEL = False # Want to use random label for train data? VALI_RANDOM_LABEL = False # Want to use random label for validation?

TRAIN_RANDOM_LABEL = False # Want to use random label for train data?
VALI_RANDOM_LABEL = False # Want to use random label for validation?

Hey Eric,

This is just for possible research purposes. Some people want to test how well the model could overfit the dataset. They may require the model to be able to overfit even when using random labels

Oh, I see. Thank you very much. By the way, your codes and annotations are very clear. Thanks for your code.

Hello wenxin,

I have another question.
# This reshape order is really important. Don't change
# Reshape is correct. Double checked
data = data.reshape((num_data, IMG_HEIGHT * IMG_WIDTH, IMG_DEPTH), order='F')
data = data.reshape((num_data, IMG_HEIGHT, IMG_WIDTH, IMG_DEPTH))
The cifar-10 datasets were processed in some special form. So we have to reshape it follow the way that the datasets were made in. Is that the reason why we process the image shape like in your code? Thank you.

“So we have to reshape it follow the way that the datasets were made in”

You are exactly right. The reshape function in numpy is a little tricky and only reshaping it in this way matches the format/order of the dataset.

Thanks!

Hello wenxin,

I come again...
There are some questions that are perplexing me.
(1) Why you change the shape of global_pool to (batch_size, 64) instead of (batch_size, 8864)?
with tf.variable_scope('fc', reuse=reuse):
in_channel = layers[-1].get_shape().as_list()[-1]
bn_layer = batch_normalization_layer(layers[-1], in_channel) #the shape hasn't been changed here

print('fc/bn_layer: ',bn_layer.get_shape()) #(250, 8, 8, 64)
relu_layer = tf.nn.relu(bn_layer)
print('fc/relu_layer: ',relu_layer.get_shape()) #(250, 8, 8, 64)
global_pool = tf.reduce_mean(relu_layer, [1, 2]) #calculate the mean of the axis
print('fc/global_pool: ', global_pool.get_shape()) #(250, 64) **here here here**!!!!!

assert global_pool.get_shape().as_list()[-1:] == [64]
output = output_layer(global_pool, 10)
layers.append(output)
(2) When I test my image like a dog.jpg. I got the the prediction like [[ 0.0952351 0.14936674 0.09992296 0.08040251 0.06085978 0.09062002
0.08599307 0.11446685 0.07660535 0.14652757]]. This is obviously a wrong answer. I don't know where the wrong operation is.( In the code I use the validation data )
vali_data, vali_labels = read_validation_data()
img = vali_data[0,...]

img = img[2:34,2:34,:]
img = img.reshape(1,32,32,3)

predictions = train.test(img)
print(predictions)

Thank you very much.

looks like no of output classes is hard coded to 10. Can you make it a variable?
output = output_layer(global_pool, 10)