representation_graphs.py 文件源码

python
阅读 38 收藏 0 点赞 0 评论 0

项目:tensorrec 作者: jfkirk 项目源码 文件源码
def relu_representation_graph(tf_features, n_components, n_features, node_name_ending):
    relu_size = 4 * n_components

    # Create variable nodes
    tf_relu_weights = tf.Variable(tf.random_normal([n_features, relu_size], stddev=.5),
                                  name='relu_weights_%s' % node_name_ending)
    tf_relu_biases = tf.Variable(tf.zeros([1, relu_size]),
                                 name='relu_biases_%s' % node_name_ending)
    tf_linear_weights = tf.Variable(tf.random_normal([relu_size, n_components], stddev=.5),
                                    name='linear_weights_%s' % node_name_ending)

    # Create ReLU layer
    tf_relu = tf.nn.relu(tf.add(tf.sparse_tensor_dense_matmul(tf_features, tf_relu_weights),
                                tf_relu_biases))
    tf_repr = tf.matmul(tf_relu, tf_linear_weights)

    # Return repr layer and variables
    return tf_repr, [tf_relu_weights, tf_linear_weights, tf_relu_biases]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号