AI学習の道(10):テンソルの定数2


tf.fill(dims、value、name=None)
指定された定数を満たすテンソルを作成します.
パラメータ:
dims:整数タイプのリストオブジェクト、または1次元テンソルは、行列形式を表します.
value:充填の定数(0次元テンソル)
 
戻り値:
指定されたテンソルを塗りつぶします.
 
例:
#python 3.5.3       
#http://edu.csdn.net/course/detail/2592  
#

import tensorflow as tf

#      
x = tf.fill([2,10], 9.)

#     
init_op = tf.global_variables_initializer()
with tf.Session() as sess:
    sess.run(init_op)
print(x.eval())
結果出力:
======================RESTART:D:/AI/sample/tf_1.21.py=========================================================================
[[9. 9. 9. 9. 9. 9. 9. 9. 9. 9.
 [9. 9. 9. 9. 9. 9. 9. 9. 9. 9.]
>>
 
tf.com nstant(value、dtype=None、shpe=None、name='Const'、verifuy shape=False)
テンソルを作成します.
パラメータ:
 
value:定数または定数リスト.
 
dtype:結果テンソルのデータタイプ.
 
shape:テンソルの行列形式は、任意です.
 
name:定数の名前は、オプションです.
 
verify_sharpe:テンソルの行列形式が正しいかどうかを検査します.
 
戻り値:
 
一つの定数のテンソル.
 
例:
#python 3.5.3       
#http://edu.csdn.net/course/detail/2592  
#

import tensorflow as tf

#      
x = tf.constant(9,shape=[2,10],dtype=tf.float32)
y = tf.constant(9,shape=[2,10],dtype=tf.int32)
z = tf.constant([1, 2, 3, 4, 5, 6, 7, 8,9],shape=[3,3],dtype=tf.float32)
#     
init_op = tf.global_variables_initializer()
with tf.Session() as sess:
    sess.run(init_op)
    print(x.eval())
    print(y.eval())
print(z.eval())
結果出力:
======================RESTART:D:/AI/sample/tf_1.2.py=========================================================================
[[9. 9. 9. 9. 9. 9. 9. 9. 9. 9.
 [9. 9. 9. 9. 9. 9. 9. 9. 9. 9.]
[[9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9]
 [9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9]]
[[1. 2. 3.
 [4. 5. 6.
 [7. 8. 9.]
>> 
1.C++標準テンプレートライブラリは入門から精通まで 
http://edu.csdn.net/course/detail/3324
2.老菜鳥にC++を学ぶ
http://edu.csdn.net/course/detail/2901
3.古い初心者にpythonを学ぶ
http://edu.csdn.net/course/detail/2592
4.VC 2015でティニーxmlライブラリの使用を学ぶ
http://edu.csdn.net/course/detail/2590
5.Windows下のSVNのバージョン管理と実戦 
 http://edu.csdn.net/course/detail/2579
6.Visual Studio 2015 C++プログラムの基本使用を開発する 
http://edu.csdn.net/course/detail/2570
7.VC 2015でprotobuf契約を使用する
http://edu.csdn.net/course/detail/2582
8.VC 2015でMySQLデータベースの使用を学ぶ
http://edu.csdn.net/course/detail/2672