本文介绍了Tensorflow:可训练的可变掩蔽的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个卷积神经网络,该网络要求内核权重的某些部分不可训练. tf.nn.conv2d(x,W)以可训练变量W作为权重.我该如何使W的某些元素变得不可训练?

I am working on a convolutional neural net that requires some parts of the a kernel weights to be untrainable. tf.nn.conv2d(x, W) takes in a trainable variable W as weights. How can I make some of the elements of W to be untrainable?

推荐答案

也许您可以设置可训练的权重W1,指示可训练变量的位置的掩码M以及恒定/不可训练的权重矩阵W2 ,并使用

Maybe you could have your trainable weights W1, a mask M indicating where the trainable variables are, and a constant / untrainable weight matrix W2, and use

W = tf.multiply(W1, tf.cast(M, dtype=W1.dtype)) + tf.multiply(W2, tf.cast(tf.logical_not(M), dtype=W2.dtype))

这篇关于Tensorflow:可训练的可变掩蔽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 21:46