What is the difference between tf.Tensor( and <tf.Tensor: >

Consider below code

import pprint

import numpy as np
import tensorflow as tf
import tensorflow_datasets as tfds
ratings = tfds.load("movielens/100k-ratings", split="train")
movies = tfds.load("movielens/100k-movies", split="train")

ratings = ratings.map(lambda x: {
    "movie_title": x["movie_title"],
    "user_id": x["user_id"],
    "user_rating": x["user_rating"],
    # "timestamp": x["timestamp"],
movies = movies.map(lambda x: x["movie_title"])
for example in movies.take(2):
  # pprint.pprint(tf.reshape(example['movie_title'],[3,5,1]))

The above code will give me output as below

<tf.Tensor: shape=(), dtype=string, numpy=b'You So Crazy (1994)'>
<tf.Tensor: shape=(), dtype=string, numpy=b'Love Is All There Is (1996)'>

Now below code will give different result.

Lets say we have below data in a csv file with name songs_details.csv

0,SOAAAGQ12A8C1420C8,Orgelblut,Dolores,Bohren  Der Club Of Gore,2008,1
1,SOAACPJ12A81C21360,Cearc Agus Coileach  The Hen And Cock,CasadhTurning,Mchel  Silleabhin,1,1
2,SOAAEJI12AB0188AB5,Godlovesugly,God Loves Ugly,Atmosphere,1,1
3,SOAAFAC12A67ADF7EB,Rome Wasnt Built In A Day,Parts Of The Process,Morcheeba,2000,2
4,SOAAKPM12A58A77210,So Confused feat Butta Creame amended album version,Late Night Special,Pretty Ricky,2007,1
5,SOAAOYI12AB01831CE,Criminal,Gotan Project live,Gotan Project,2006,2

Now lets read this csv file and process it

songs = tf.data.experimental.make_csv_dataset(
songs = songs.unbatch().map(lambda x: {

for example in songs.map(lambda x: x['title']).take(2):

The above will produce output as below

tf.Tensor(b'Skip The Youth', shape=(), dtype=string)
tf.Tensor(b'Teenage Dirtbag', shape=(), dtype=string)

are there any difference between the two representation of variables, I mean between tf.Tensor() and <tf.Tensor: >

1 Like

Looks like using different print function is the issue. At first I have used pprint and in second one I have used print, otherwise both are same. python - What is the difference between tf.Tensor( and <tf.Tensor: > - Stack Overflow

1 Like