Open zeynepgokce opened 7 years ago
hello, when you call saver.restore(sess, model_filename) ),the model_filename parameter can be assigned by:
'model_filename=tf.trainable_variables()' for all trainable parameters in the checkpoint,
in your case,:
'model_filename= [v for v in tf.trainable_variables() if v.name.find("conv") != -1]' this means only restore the conv layer.
and you can print all layer name like this:
'for i in tf.trainable_variables():
print(i.name)
'
strongly advise you to get more familiar with tensorflow.
But model_filename is a path and it is pretrained model as following part in the python file. **model_filename = "./sports1m_finetuning_ucf101.model"
if os.path.isfile(model_filename) and use_pretrained_model: saver.restore(sess, model_filename)**
then i couldn't use the restore method according to code part which you gave.
checkout https://github.com/hx173149/C3D-tensorflow/blob/master/C3D-tensorflow-1.0/Random_clip_valid.py,
my bad to ignore that model_filename is a path. when you define the saver by : saver = tf.train.Saver()
you can also do it by assign variables name: var_list = [v for v in tf.trainable_variables() if v.name.find("conv") != -1] saver = tf.train.Saver(var_list )
and then when you call: saver.restore(sess, model_filename) this will only resotre the variables in var_list instaead of all variables in the "./sports1m_finetuning_ucf101.model".
just like what i did in the repo:C3D-tensorflow-1.0/Random_clip_valid.py--more useful code here.
Ok, thank you so much, i got this part. but now, I got different error. I couldnt solve, I just tried to train your model with 2 video and just changed parameters to batch size = 1 and gpu_num =1 in original code and the other parts are same , again i got the same error
It gives the error in 3. line of the above code part as following :
% (np_val.shape, subfeed_t.name, str(subfeed_t.get_shape()))) ValueError: Cannot feed value of shape (1, 0) for Tensor u'Placeholder:0', which has shape '(1, 16, 112, 112, 3)'
train_labels shape should be (1) , so why placeholder shape is (1, 16, 112, 112, 3) ? how can i solve it ?
This is because your input is video,however the code's input is frame.
@zeynepgokce @zzy123abc Hi, I have already achieved better precision on UCF101 according to the tutorial, but I now want to use my own video data to fine tune with the provided pre-training model (I have a very big doubt: train_c3d_ucf101.py in the tensorflow folder actually That is, fine-tuning the code, can you modify the pre-training model you need in the code?). My video data has 20 categories. Do I need to modify softmax to correspond to my own number of categories? Looking forward to your reply! Thank you!
of course,you need to modify fc to 20.
@zzy123abc Thank you for your reply! I still have a question. I want to use my own video data for training and prediction. The author of this paper has given four pre-training models. Which model will I use better?
@zeynepgokce Hi, I am training a new model with the HMDB51 dataset, which has only 51 classes. Through the pre-training model given by the author, I want to fine-tune the parameters behind fc, but how the code should be modified, I tried it many times without success.
saver = tf.train.Saver(weights.values() + biases.values()) init = tf.global_variables_initializer()
sess = tf.Session( config=tf.ConfigProto(allow_soft_placement=True) ) sess.run(init) if os.path.isfile(model_filename) and use_pretrained_model: saver.restore(sess, model_filename)
I hope to get your help! Thanks.
Hi, I am new in this area as i mentioned before. I am trying to apply fine tuning to this model. In pre-trained model there are 101 classes but i want to change it to 2 classes by applying fine tuning, but when i restore the model ( saver.restore(sess, model_filename) ) i have encountered error something like this " InvalidArgumentError (see above for traceback): Assign requires shapes of both tensors to match. lhs shape= [2] rhs shape= [101] " I guess, i shouldn't restore the out layer from the pretrained model. Am i wrong? If i am wrong what should i do to solve this problem? If i am right, how can i restore the model without out layer?
Can you help me ?
The error : -- By the way, fine_tuning.py is the same with the train code in this project. İ just change the name. **1. Traceback (most recent call last):