當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python tensorflow.IndexedSlicesSpec()用法及代碼示例

TensorFlow是Google設計的開源Python庫,用於開發機器學習模型和深度學習神經網絡。

IndexedSlicesSpec繼承自TypeSpec,並擴展IndexedSlices的Type規範。

用法:tensorflow.IndexedSlicesSpec( shape, dtype, indices_dtype, dense_shape_dtype, indices_shape )

參數:

  • shape(optional):它定義了IndexedSlices的密集形狀。默認值為“無”,允許任何密集的形狀。
  • dtype(optinal):它定義IndexedSlices值的dtype。默認值為float32。
  • indices_dtype(可選):它在IndexedSlices中定義索引的dtype。它可以是int32或int64,默認值為int64。
  • dense_shape_dtye(可選):它在IndexedSlices中定義了密集形狀的dtype。它可以是int32,int64或None(默認值為None)。
  • indices_shape(可選):它定義了索引組件的形狀,該組件指示IndexedSlices中有多少個切片。

範例1:本示例使用所有默認值。



Python3

# Importing the library 
import tensorflow as tf 
  
# Calculating result 
res = tf.IndexedSlicesSpec() 
  
# Printing the result 
print('IndexedSlicesSpec:', res)

輸出:

IndexedSlicesSpec: IndexedSlicesSpec(TensorShape(None), tf.float32, tf.int64, None, TensorShape([None]))

範例2:

Python3

# Importing the library 
import tensorflow as tf 
  
# Calculating result 
res = tf.IndexedSlicesSpec((2, 3)) 
  
# Printing the result 
print('IndexedSlicesSpec:', res)

輸出:

IndexedSlicesSpec: IndexedSlicesSpec(TensorShape([2, 3]), tf.float32, tf.int64, None, TensorShape([None]))


相關用法


注:本文由純淨天空篩選整理自aman neekhara大神的英文原創作品 Python – tensorflow.IndexedSlicesSpec()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。