zoukankan      html  css  js  c++  java
  • tensorflow softmax应用

    ---恢复内容开始---

    1、softmax函数

    2、tensorflow实现例子

    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    
    import tensorflow as tf
    
    input_data = tf.Variable( [[0.2, 0.2, 0.2]] , dtype = tf.float32 )
    output = tf.nn.softmax(input_data)
    with tf.Session() as sess:
        init = tf.initialize_all_variables()
        sess.run(init)
        print(sess.run(input_data))
        print(sess.run(output))
        print(sess.run(tf.shape(output)) )

    输出为:

    [[ 0.2 0.2 0.2]]
    [[ 0.33333334 0.33333334 0.33333334]]
    [1 3]

    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    
    import tensorflow as tf
    
    input_data = tf.Variable( [[0.2, 0.2, 0.2],[1,2,3]] , dtype = tf.float32 )
    output = tf.nn.softmax(input_data)
    with tf.Session() as sess:
        init = tf.initialize_all_variables()
        sess.run(init)
        print(sess.run(input_data))
        print(sess.run(output))
        print(sess.run(tf.shape(output)) )
    

      

      输出为:

    [[ 0.2 0.2 0.2]
    [ 1. 2. 3. ]]
    [[ 0.33333334 0.33333334 0.33333334]
    [ 0.09003057 0.24472848 0.66524094]]
    [2 3]

  • 相关阅读:
    HDU 4472 Count DP题
    HDU 1878 欧拉回路 图论
    CSUST 1503 ZZ买衣服
    HDU 2085 核反应堆
    HDU 1029 Ignatius and the Princess IV
    UVa 11462 Age Sort
    UVa 11384
    UVa 11210
    LA 3401
    解决学一会儿累了的问题
  • 原文地址:https://www.cnblogs.com/lovephysics/p/7219070.html
Copyright © 2011-2022 走看看