【问题标题】:Parameterized model over output functions using tensorflow使用张量流的输出函数的参数化模型
【发布时间】:2016-01-23 21:10:04
【问题描述】:

是否可以使用 tensorflow 对输出函数进行参数化模型?如何?

示例: 我想要最后使用 softmax 函数的模型,所以

cost = tf.reduce_mean(
    tf.nn.softmax_cross_entropy_with_logits(output_potentials, y))

但是我想尝试 sigmoidal 输出和均方,在这种情况下:

cost = tf.reduce_sum(
    tf.pow(tf.sub(tf.nn.sigmoid(output_potentials), y), 2.0))

我的问题是,如何制作具有成本函数规范的参数化模型?在为此类模型调用构造函数之前,我没有 tensorflow 占位符。

【问题讨论】:

    标签: python tensorflow parameterized


    【解决方案1】:

    将两个函数都放在图中,然后在评估期间调用其中一个或另一个。评估框架将在评估期间选择特定版本成本所需的图表子集

    cost1 = tf.reduce_mean(
        tf.nn.softmax_cross_entropy_with_logits(output_potentials, y))
    cost2 = tf.reduce_sum(
        tf.pow(tf.sub(tf.nn.sigmoid(output_potentials), y), 2.0))
    sess.run([cost1])
    sess.run([cost2])
    

    【讨论】:

    猜你喜欢
    • 2018-05-03
    • 2021-10-07
    • 2019-01-18
    • 1970-01-01
    • 2018-12-22
    • 2018-06-23
    • 1970-01-01
    • 2017-05-15
    相关资源
    最近更新 更多