tensorflow :: ops :: Bitcast
#include <array_ops.h>
Bitcast suatu tensor dari satu jenis ke jenis lainnya tanpa menyalin data.
Ringkasan
Dengan adanya input
tensor, operasi ini mengembalikan tensor yang memiliki data buffer yang sama dengan input
dengan tipe type
data.
Jika datatype masukan T
lebih besar dari output datatype type
maka perubahan bentuk dari [...] untuk [..., sizeof ( T
) / sizeof ( type
)].
Jika T
lebih kecil dari type
, operator mensyaratkan bahwa dimensi paling kanan harus sama dengan sizeof ( type
) / sizeof ( T
). Bentuknya kemudian berubah dari [..., sizeof ( type
) / sizeof ( T
)] menjadi [...].
tf.bitcast () dan tf.cast () bekerja secara berbeda ketika dtype nyata dicor sebagai dtype kompleks (mis. tf.complex64 atau tf.complex128) sebagai tf.cast () buat bagian imajiner 0 sementara tf.bitcast () memberikan modul kesalahan. Sebagai contoh,
Contoh 1:
a = [1., 2., 3.] equality_bitcast = tf.bitcast (a, tf.complex128) Traceback (panggilan terakhir terakhir): ... InvalidArgumentError: Tidak bisa bitcast dari 1 hingga 18 [Op: Bitcast ] equality_cast = tf.cast (a, tf.complex128) print (equality_cast) tf.Tensor ([1. + 0.j 2. + 0.j 3. + 0.j], shape = (3,), dtype = complex128)
Contoh 2:
tf.bitcast (tf.constant (0xffffffff, dtype = tf.uint32), tf.uint8)
Contoh 3:
x = [1., 2., 3.] y = [0., 2., 3.] persamaan = tf. sama (x, y) equality_cast = tf.cast (persamaan, tf.float32) equality_bitcast = tf. bitcast (equality_cast, tf.uint8) print (persamaan) tf.Tensor ([False True True], shape = (3,), dtype = bool) print (equality_cast) tf.Tensor ([0. 1. 1.], shape = (3,), dtype = float32) print (equality_bitcast) tf.Tensor ([[0 0 0 0] [0 0 128 63] [0 0 128 63]], shape = (3, 4), dtype = uint8)
CATATAN : Bitcast diimplementasikan sebagai cast tingkat rendah, sehingga mesin dengan urutan endian yang berbeda akan memberikan hasil yang berbeda.
Argumen:
- scope: Objek Scope
Pengembalian:
-
Output
: Tensor keluaran.
Pembuat dan Penghancur | |
---|---|
Bitcast (const :: tensorflow::Scope & scope, :: tensorflow::Input input, DataType type) |
Atribut publik | |
---|---|
operation | |
output |
Fungsi publik | |
---|---|
node () const | ::tensorflow::Node * |
operator::tensorflow::Input () const | |
operator::tensorflow::Output () const |
Atribut publik
operasi
Operation operation
keluaran
::tensorflow::Output output
Fungsi publik
Bitcast
Bitcast( const ::tensorflow::Scope & scope, ::tensorflow::Input input, DataType type )
simpul
::tensorflow::Node * node() const
operator :: tensorflow :: Input
operator::tensorflow::Input() const
operator :: tensorflow :: Keluaran
operator::tensorflow::Output() const