ValueError: Variable E_conv0/w/Adam/ does not exist, or was not created with tf.get_variable().
来源:互联网 发布:淘宝余潇潇是谁 编辑:程序博客网 时间:2024/05/16 11:04
运行tf.train.AdamOptimizer()函数,例如下面代码:
self.EG_optimizer = tf.train.AdamOptimizer( learning_rate=EG_learning_rate, beta1=beta1 ).minimize( loss=self.loss_EG, global_step=self.EG_global_step, var_list=self.E_variables + self.G_variables )
出现错误:ValueError: Variable E_conv0/w/Adam/ does not exist, or was not created with tf.get_variable(). Did you mean to set reuse=None in VarScope?
解决方法:
在函数第一行添加:
with tf.variable_scope("encoder") as scope:
例如原encoder()函数代码为:
def encoder(self, image, reuse_variables=False): if reuse_variables: tf.get_variable_scope().reuse_variables() num_layers = int(np.log2(self.size_image)) - int(self.size_kernel / 2) current = image # conv layers with stride 2 for i in range(num_layers): name = 'E_conv' + str(i) current = conv2d( input_map=current, num_output_channels=self.num_encoder_channels * (2 ** i), size_kernel=self.size_kernel, name=name ) current = tf.nn.relu(current) # fully connection layer name = 'E_fc' current = fc( input_vector=tf.reshape(current, [self.size_batch, -1]), num_output_length=self.num_z_channels, name=name ) # output return tf.nn.tanh(current)
修改后为:def encoder(self, image, reuse_variables=False): with tf.variable_scope("encoder") as scope: if reuse_variables: tf.get_variable_scope().reuse_variables() num_layers = int(np.log2(self.size_image)) - int(self.size_kernel / 2) current = image # conv layers with stride 2 for i in range(num_layers): name = 'E_conv' + str(i) current = conv2d( input_map=current, num_output_channels=self.num_encoder_channels * (2 ** i), size_kernel=self.size_kernel, name=name ) current = tf.nn.relu(current) # fully connection layer name = 'E_fc' current = fc( input_vector=tf.reshape(current, [self.size_batch, -1]), num_output_length=self.num_z_channels, name=name ) # output return tf.nn.tanh(current)
阅读全文
0 0
- ValueError: Variable E_conv0/w/Adam/ does not exist, or was not created with tf.get_variable().
- ValueError: Variable RNN/MultiRNNCell/Cell0/BasicLSTMCell/Linear/Matrix does not exist, disallowed.
- table or view does not exist -- oracle
- table or view does not exist
- extjs [W] Ext.data.Store created with no model. The name 'RCP.model.WeChatUser' does not correspond
- does not exist or is not a readable directory
- ..\TestApp does not exist or is not a readable directory
- FRM-40815:Variable GLOBAL.JOBS_QF_FIND_CLKT / GLOBAL.PRIOR_COMPLETION_PROG_UNIT Does Not Exist
- Tensorflow cifar10_multi_gpu问题:Variable conv1/weights/ExponentialMovingAverage/ does not exist
- DocumentRoot does not exist
- mapreduce_shuffle does not exist
- @Scripts “does not exist”
- 'resourceFile' does not exist.
- This Toast was not created with Toast.makeText()的解决办法
- This Toast was not created with Toast.makeText()
- [VB.NET]Object variable or With block variable not set
- ErrorList:Object variable or With block variable not set error
- ORA-00942:table or view does not exist
- Advanced REST client的安装
- Flume架构以及应用介绍
- Java代理模式
- 强连通缩点
- java设计模式之建造者模式
- ValueError: Variable E_conv0/w/Adam/ does not exist, or was not created with tf.get_variable().
- 新网站如何做好seo优化
- 实现横向排列的几种方案
- sqlserver截取日期的年份和月份
- Cobbler批量布署CentOS
- Node.js搭建Express应用程序
- 搜狐狐友营销的十二个办法
- iOS11新特性
- MySQL 加锁处理分析