AttributeError: module ‘tf_slim.layers.layers‘ has no attribute ‘xavier_initializer‘ 解决方案

问题描述

错误代码:

from tf_slim import layers as tf_layers

def create_MLP(self, name, output_dim, hidden_sizes,
               hidden_W_init=tf_layers.xavier_initializer(), hidden_b_init=tf.zeros_initializer(),
               output_W_init=tf_layers.xavier_initializer(), output_b_init=tf.zeros_initializer(),
               weight_normalization=False,
               ):
    all_params = OrderedDict()

报错:

AttributeError: module 'tf_slim.layers.layers' has no attribute 'xavier_initializer' 

解决方案

将from tf_slim import layers as tf_layers改成

from tf_slim.layers import initializers as tf_layers

你可能感兴趣的:(tensorflow,python,bug解决方案,python,tensorflow)