小编Muh*_*mad的帖子

在 TensorFlow 中修改恢复的 CNN 模型的权重和偏差

我最近开始使用 TensorFlow (TF),遇到了一个需要帮助的问题。基本上,我已经恢复了一个预训练的模型,在重新测试其准确性之前,我需要修改其中一层的权重和偏差。现在,我的问题如下:如何使用assignTF 中的方法更改权重和偏差?是否可以在 TF 中修改恢复建模的权重?

这是我的代码:

import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data # Imports the MINST dataset

# Data Set:
# ---------
mnist = input_data.read_data_sets("/home/frr/MNIST_data", one_hot=True)# An object where data is stored

ImVecDim = 784# The number of elements in a an image vector (flattening a 28x28 2D image)
NumOfClasses = 10

g = tf.get_default_graph()

with tf.Session() as sess:
  LoadMod = tf.train.import_meta_graph('simple_mnist.ckpt.meta')  # This object loads the model
  LoadMod.restore(sess, tf.train.latest_checkpoint('./'))# Loading weights and biases and …
Run Code Online (Sandbox Code Playgroud)

python machine-learning deep-learning tensorflow

5
推荐指数
1
解决办法
8461
查看次数