对影响学习的体重和偏见依赖性感到困惑

我有一个有效的LSTM模型,它具有从其经常状态到输出的一个权重/偏置层。 然后我也编写了相同的系统,但有两层。 这意味着我将拥有LSTM,然后是隐藏层,然后是输出。 我写了几行来定义这个双层模型,但并没有单独使用它们。 但是,现在这些图层存在但完全没有使用,它不会学习! 所以我的权重和偏见是这样定义的:

    weights = {                                                                                                                                                               
        # if going straight from PLSTM output to x,y prediction                                                                                                               
        'out': tf.Variable(tf.random_normal([FLAGS.n_hidden, n_out], stddev=1/FLAGS.n_hidden, dtype=tf.float32)),                                                             

        # if fully connected feed-forward hidden layer between PLSTM output and x,y prediction                                                                                
        'outHidden1': tf.Variable(tf.random_normal([FLAGS.n_hidden, FLAGS.n_middle], dtype=tf.float32)),                                                                    
        'outHidden2': tf.Variable(tf.random_normal([FLAGS.n_middle, n_out], dtype=tf.float32))                                                                              
    }                                                                                                                                                                         

    biases = {                                                                                                                                                                
        # if going straight from PLSTM output to x,y prediction                                                                                                               
        'out': tf.Variable(tf.random_normal([n_out], dtype=tf.float32)),                                                                                                      

        # if fully connected feed-forward hidden layer between PLSTM output and x,y predictio                                                                                 
        'outHidden1': tf.Variable(tf.random_normal([FLAGS.n_middle], dtype=tf.float32)),                                                                                    
        'outHidden2': tf.Variable(tf.random_normal([n_out], dtype=tf.float32))                                                                                              
    }

所以我定义了双层权重和偏差,但他们从未在培训或测试中使用过一次。

我把重量/偏差结合在一起:

    return tf.matmul(relevant, weights['out']) + biases['out']

相关的是LSTM输出。 所以我只在重量和偏见词典中使用'out'变量。

它不会学到任何东西。 然后,一旦我像这样评论双层变量:

    weights = {                                                                                                                                                               
        # if going straight from PLSTM output to x,y prediction                                                                                                               
        'out': tf.Variable(tf.random_normal([FLAGS.n_hidden, n_out], stddev=1/FLAGS.n_hidden, dtype=tf.float32)),                                                             

        # if fully connected feed-forward hidden layer between PLSTM output and x,y prediction                                                                                
        # 'outHidden1': tf.Variable(tf.random_normal([FLAGS.n_hidden, FLAGS.n_middle], dtype=tf.float32)),                                                                    
        # 'outHidden2': tf.Variable(tf.random_normal([FLAGS.n_middle, n_out], dtype=tf.float32))                                                                              
    }                                                                                                                                                                         

    biases = {                                                                                                                                                                
        # if going straight from PLSTM output to x,y prediction                                                                                                               
        'out': tf.Variable(tf.random_normal([n_out], dtype=tf.float32)),                                                                                                      

        # if fully connected feed-forward hidden layer between PLSTM output and x,y predictio                                                                                 
        # 'outHidden1': tf.Variable(tf.random_normal([FLAGS.n_middle], dtype=tf.float32)),                                                                                    
        # 'outHidden2': tf.Variable(tf.random_normal([n_out], dtype=tf.float32))                                                                                              
    }

...它再次开始工作。 这些变量的存在如何妨碍学习? 我初始化它们,但是不应该通过它们运行渐变,并且backprop应该与这些未使用的变量没有任何关联。 或者我误解了一些东西?

链接地址: http://www.djcxy.com/p/32127.html

上一篇: Confused about weight and bias dependencies affecting learning

下一篇: how to stack LSTM layers using TensorFlow