简体   繁体   English

tf.train.Saver中的var_list是什么意思?

[英]what does var_list in tf.train.Saver mean?

I check the tensorflow API, If None, the var_list is defaults to the list of all saveable objects. 我检查tensorflow API,如果为None,则var_list默认为所有可保存对象的列表。 I want to know what does the all saveable objects mean? 我想知道所有可保存对象的含义是什么? tf.global_variables? tf.global_variables? W = tf.get_variable("W", shape=[784, 256], initializer=tf.contrib.layers.xavier_initializer()) b = tf.get_variable("b", shape=[784, 256], initializer=tf.contrib.layers.xavier_initializer()) m = tf.add(W, b) Does m belongs to tf.global_variables? W = tf.get_variable(“ W”,shape = [784,256],初始值设定项= tf.contrib.layers.xavier_initializer())b = tf.get_variable(“ b”,shape = [784,256],初始值设定项= tf.contrib.layers.xavier_initializer())m = tf.add(W,b)m是否属于tf.global_variables? I am really confused. 我真的很困惑。 在此处输入图片说明 Here is my graph, I found train and loss node exists, so do I save the train and loss node? 这是我的图,我发现训练和损失节点存在,那么我要保存训练和损失节点吗? I just want to save model weights..... 我只想保存模型重量.....

The var_list variable says what it does, you may sometimes not want to save the entire model and only a part of it, for these purposes this list can be used, let me elaborate var_list变量说明了它的作用,您有时可能不希望保存整个模型,而只保存一部分模型,出于这些目的,可以使用此列表,让我详细说明一下

I am working on face recognition and i trained a CNN that extracts information from face images and gives a 512 size array of encodings that i can then pass to a SVM that can map these embeddings to a name, now at training i need the svm (or a simple ANN) i dont need it during inference, and saving its weights will lead to a larger model size and will consume more GPU memory, so i can while saving decide to store only the CNN variables, not the SVM/ANN ones, hence i will pass names of the layers of the CNN in var_list and not names of the layers of the SVM 我正在研究人脸识别,并且训练了一个CNN,该CNN从人脸图像中提取信息并提供512大小的编码数组,然后我可以将其传递给可以将这些嵌入映射到名称的SVM,现在在训练中我需要svm(或简单的ANN),在推理过程中我不需要它,并且保存其权重将导致更大的模型尺寸并消耗更多的GPU内存,因此我可以在保存时决定只存储CNN变量,而不存储SVM / ANN变量,因此,我将在var_list中传递CNN层的名称,而不是SVM层的名称

Another aspect of saving for inference is that layers like dropout are useless during inference, so its best not to store them at all as they take a chunk of memory 进行推理保存的另一个方面是,像dropout这样的层在推理过程中是无用的,因此最好不要完全存储它们,因为它们会占用大量内存

In your case i would suggest dont use it and save the model as it is 在您的情况下,我建议不要使用它并按原样保存模型

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM