Giter Site home page Giter Site logo

Checkpoint about tensorflow-cnn-finetune HOT 7 CLOSED

dgurkaynak avatar dgurkaynak commented on June 20, 2024
Checkpoint

from tensorflow-cnn-finetune.

Comments (7)

dgurkaynak avatar dgurkaynak commented on June 20, 2024 2

Hey @arminXerror, I have given a sample code to perform just prediction in another issue, please check #4 (comment). I haven't tested the code, but you can get the idea.

from tensorflow-cnn-finetune.

dgurkaynak avatar dgurkaynak commented on June 20, 2024 1
  1. You should try different values, every dataset is different. In my experiences, I got best scores with 224,256.
  2. Yes.
  3. Yes.
  4. If you want to online training, you can think like a batch with size 1.
  5. You should search and implement it yourself. You have already asked about confusion matrix in #5.

from tensorflow-cnn-finetune.

dgurkaynak avatar dgurkaynak commented on June 20, 2024 1

If the number of your classes is not 1000, the weights of final layer is initialised from scratch. You don't have to do anything.

from tensorflow-cnn-finetune.

dgurkaynak avatar dgurkaynak commented on June 20, 2024 1

In fact skip_layers is not used at all. Look at load_original_weights method:

def load_original_weights(self, session, skip_layers=[]):
weights_path = 'ResNet-L{}.npy'.format(self.depth)
weights_dict = np.load(weights_path, encoding='bytes').item()
for op_name in weights_dict:
parts = op_name.split('/')
# if contains(op_name, skip_layers):
# continue
if parts[0] == 'fc' and self.num_classes != 1000:
continue
full_name = "{}:0".format(op_name)
var = [v for v in tf.global_variables() if v.name == full_name][0]
session.run(var.assign(weights_dict[op_name]))

Initially it was used for skipping weight transfer for that layers. Later, I commented out that check because I wanted to transfer weights for all layers except the last layer. Starting these layers from transferred weights performs better than initialising random. If you want to initalise them random, you can uncomment these 2 lines.

from tensorflow-cnn-finetune.

Auth0rM0rgan avatar Auth0rM0rgan commented on June 20, 2024

Hey @dgurkaynak,

Sorry for taking your time, I am trying to understand your code line by line and have questions in my mind I would be appreciated if you can help me to find out the answer.

  1. In the line for multi_scale should I give a number for multi_scale or it has a default number which is 2?
    tf.app.flags.DEFINE_string('multi_scale', ' **??** ', 'As preprocessing; scale the image randomly between 2 numbers and crop randomly at network\'s input size')

  2. Are you calculating the accuracy as average accuracy on each epoch? for example, if I have 3K images for my val_data and batch size is 128. According to this line
    val_batches_per_epoch = np.floor(len(val_preprocessor.labels) / FLAGS.batch_size).astype(np.int16)
    my val_batches_per_epoch is 23 which means for completing 1 epoch, you are feeding network 23 times and each time you calculate the accuracy and at the end of the first epoch you sum up all accuracy and get the average, am I right?

  3. If I want to know about training accuracy should I do it as follow:
    opt, tr_acc = sess.run([train_op, accuracy], feed_dict={x: batch_xs, y: batch_ys, is_training: True})
    and then print the tr_acc. Is it a correct way to get train accuracy?

  4. If I want to feed network without batch size what should be variable?
    feed_dict={x: batch_xs, y: batch_ys, is_training: False})
    I mean what should be the variable for x and y without next batch, I have tried val_preprocessor.images for x and val_preprocessor.labels but I got an error which these 2 are string and must be float. you are reading images from text file and converting the images and labels to numpy array, how can i get these numpy array in finetune.py ?

  5. Could you please help me to get the accuracy for each category if you have 10 categories and wants to know accuracy of each one and plot curves per category for your network?

I know is so much....

thanks in advance.

from tensorflow-cnn-finetune.

Auth0rM0rgan avatar Auth0rM0rgan commented on June 20, 2024

Hey @dgurkaynak,

I really appreciate your help.

If I want to remove the weights of the final layer and "re-train" the net again with the new data set. Should I do as follow?

In ResNet, you load pre-trained weights as follow:

model.load_original_weights(sess, skip_layers=train_layers) which, train_layers is FC layer in ResNet.

should I just remove skip_layers and change the line like below?
model.load_original_weights(sess)

is going to re-train the net again with my new data set or I have to change another part as well?

Thanks in advance.

from tensorflow-cnn-finetune.

Auth0rM0rgan avatar Auth0rM0rgan commented on June 20, 2024

Hey @dgurkaynak,

Great, I have 10 classes in my dataset.

What will happen to the network if I remove skip_layers as explained?
Where did you define for the network if the number of classes is less than 1000, the weights of the final layer will initialize from scratch?

Thanks in advance.

from tensorflow-cnn-finetune.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.