0

I am following the view on youtube here,

it shows the code

text_1 = tf.ragged.constant(
    [['who','is', 'Goerge', 'Washington'],
     ['What', 'is', 'the', 'weather', 'tomorrow']])
text_2 = tf.ragged.constant(['goodnight'])

text = tf.concat(text_1, text_2)
print(text)

But it raises the ValueError as follows:

ValueError: Tensor conversion requested dtype int32 for Tensor with dtype string:

What is wrong please?

chikitin
  • 762
  • 6
  • 28

2 Answers2

0

In the docs it says that concat takes a list of tensors and an axis as arguments, like so

text = tf.concat([text_1, text_2], axis=-1)

This raises a ValueError because the shapes of the tensors don't match. Please specify what you want to achieve.

Edit:

In the video you linked to there appears to be a syntax error in this line: text_2 = tf.ragged.constant(['goodnight']]). (The brackets don't match.) It should really be text_2 = tf.ragged.constant([['goodnight']]), which achieves the result printed below the operation in the video.

felixwege
  • 121
  • 1
  • 6
0

The tf.concat requires one list of tensors and a axis. And the text_2 should have the same dimentions of text_1

text_1 = tf.ragged.constant(
    [['who', 'is', 'Goerge', 'Washington'],
     ['What', 'is', 'the', 'weather', 'tomorrow']])
text_2 = tf.ragged.constant([['goodnight']])

text = tf.concat([text_1, text_2], 0)
print(text)
yolisses
  • 136
  • 2
  • 9