Attributes of tensorflow operations

Consider the following example:

a=tf.constant([[1,2,3],[4,5,6]],shape=(2,3),name="a")
b=a+1

It will produce the following graph:

We can see a constant tensorflow operation has two attributes: dtype is the type of the elements stored in the tensor; value is the tensor. The value is a python dict with the single key:”tensor”. The value of “tensor” is another python dict with the keys: “dtype”, “tensor_shape”, and “tensor_content”. The “dtype” is the data type of the elements in the data.  “tensor_shape” describes the shape of the data, again it is a python dict with only one key “dim”. The “dim” is a list of dicts. Every dict in the list has single key “size” that is the size of a dimension of the data. For a scalar constant, the “tensor_shape” is an empty dict. The “tensor_content” is the data itself which is represented by octet strings. Every number in the data is represented by 4 octet strings.  For scalar constants, it uses a key like “int_val” instead of “tensor_content” to store the content of the data.

For operations that do not store data, there would be no dtype and value attributes. Instead, they may have a T attribute to indicate the data type of its output.

 

Did you like this?
Tip admin with Cryptocurrency

Donate Bitcoin to admin

Scan to Donate Bitcoin to admin
Scan the QR code or copy the address below into your wallet to send some bitcoin:

Donate Bitcoin Cash to admin

Scan to Donate Bitcoin Cash to admin
Scan the QR code or copy the address below into your wallet to send bitcoin:

Donate Ethereum to admin

Scan to Donate Ethereum to admin
Scan the QR code or copy the address below into your wallet to send some Ether:

Donate Litecoin to admin

Scan to Donate Litecoin to admin
Scan the QR code or copy the address below into your wallet to send some Litecoin:

Donate Monero to admin

Scan to Donate Monero to admin
Scan the QR code or copy the address below into your wallet to send some Monero:

Donate ZCash to admin

Scan to Donate ZCash to admin
Scan the QR code or copy the address below into your wallet to send some ZCash:

Leave a Reply