Python - tensorflow.constant_initializer()
TensorFlow ist eine Open-Source-Python-Bibliothek, die von Google entwickelt wurde, um Modelle für machine learning und neuronale Netzwerke für deep learning zu entwickeln.
constant_initializer() ist ein Initialisierer, der einen Tensor mit konstantem Wert generiert.
Syntax: tensorflow.constant_initializer (Wert)
Parameter:
- value: Dies ist der Wert, der in Tensor konvertiert werden musste. Dies kann ein Python-Skalar, eine Liste oder ein Tupel von Werten oder ein N-dimensionales Numpy-Array sein
Rückgabe : Gibt eine Initializer-Instanz zurück.
Beispiel 1: Aus der Python-Liste
import
tensorflow as tf
l
=
[
1
,
2
,
3
,
4
]
(
'l: '
, l)
x
=
tf.constant_initializer(l)
(
'x: '
, x)
Ausgabe:
l: [1, 2, 3, 4] x: tensorflow.python.ops.init_ops_v2.Constant-Objekt bei 0x7fa7f2e1ab00
Beispiel 2: Aus Python-Tupel
import
tensorflow as tf
l
=
(
1
,
2
,
3
,
4
)
(
'l: '
, l)
x
=
tf.constant_initializer(l )
(
'x: '
, x)
Ausgabe:
l: (1, 2, 3, 4) x: tensorflow.python.ops.init_ops_v2.Constant-Objekt bei 0x7fa7f2e1ab00