chinese-book icon indicating copy to clipboard operation
chinese-book copied to clipboard

ch3.5 p69 line 30 ReconLayer.pretrain denoise_name not including variable_scope

Open arisliang opened this issue 7 years ago • 8 comments

假设设置variable_scope (say 'ae'),denoise_name仍然会用本身的名字denoising1,而不是ae/denoising1. 不然有KeyError。如果有不同scope相同denoise_name的情况下,是不是就没法区别呢?

with tf.variable_scope("ae", reuse=reuse): ... recon_layer1.pretrain(sess, x=x, X_train=X_train, X_val=X_val, denoise_name='ae/denoising1', n_epoch=n_epochs, batch_size=batch_size, print_freq=print_interval, save=True, save_name='w1pre_')

logging.info(" denoising layer keep: %f" % self.all_drop[set_keep[denoise_name]]) KeyError: 'ae/denoising1'

arisliang avatar Mar 02 '18 01:03 arisliang

书里没有with tf.variable_scope("ae", reuse=reuse):哦,你自己改的吗?

zsdonghao avatar Mar 02 '18 12:03 zsdonghao

对,自己加了一个scope, 因为想要对train和test使用reuse,然后发现recon_layer1.pretrain好像有这个问题,其他的layer没有发现这个问题。

arisliang avatar Mar 02 '18 13:03 arisliang

能否把代码都贴上来,我看了下 ReconLayer的源码,没发现问题~

zsdonghao avatar Mar 02 '18 13:03 zsdonghao

代码在https://gist.github.com/arisliang/64d1bbdddc5eba0fd6cb9d3ba0ccabce, line 102

arisliang avatar Mar 02 '18 13:03 arisliang

It seems that your code is different with the official code here

wagamamaz avatar Mar 12 '18 14:03 wagamamaz

Yes, i added the variable scope, supposedly the layer name should include the scope. But pretrain can't find the denoise layer if the model is under a scope.

arisliang avatar Mar 12 '18 15:03 arisliang

I test the code after adding variable_scope , it works well.

zsdonghao avatar Mar 13 '18 11:03 zsdonghao

which code did you test, official example? Are you able to reproduce the error using my code?

arisliang avatar Mar 13 '18 13:03 arisliang