I'm trying to create a Transformer Model, I have 2 np.arrays
, both have strings, I used them to create a list of tuples
The format of the tuple is :
class 'tuple' (tf.Tensor: shape=(), dtype=string, numpy=b'abc', tf.Tensor: shape=(), dtype=string, numpy=b'xyz')
I want to combine these tuples to form tensorflow.python.data.ops.dataset_ops._OptionsDataset
, how can I do that?
Or is there any other way I could do it?
New to this, thanks for your help!
You can use tensor_from_slices
. Here .
EDIT
Example
# Two tensors can be combined into one Dataset object.
values1 = tf.constant(['A', 'B', 'A']) # ==> 3x1 tensor
values2 = tf.constant(['A', 'B', 'A']) # ==> 3x1 tensor
dataset = Dataset.from_tensor_slices((values1, values2))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.