How to explain "tff.to_type((tf.int64, [2]))"?

Issue

I am learning Tensorflow-Federated, while I don’t know how to explain the syntax tff.to_type((tf.int64, [2])). I consider tff.to_type can create a tff data type, but I don’t know the meaning of [2].

Solution

So, tff.to_type creates a tff type with the dtype tf.int64 and the shape [2]. It is like defining a tf.TensorSpec that describes the properties of a tensor. It has a shape argument as well as a dtype argument. For better understanding, run:

import tensorflow as tf
tf.TensorSpec(dtype=tf.int64, shape=[2])
TensorSpec(shape=(2,), dtype=tf.int64, name=None)

This tensor will, therefore, have two values with the data type tf.int64.

Answered By – AloneTogether

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published