Reputation: 31
Hi am trying to get the length of files. am using tf version 1.14.0 and keras 2.2.4. But the below code is written in 2.6 version. Am getting error:
TypeError: object of type 'Tensor' has no len()
Can anyone help to change the code for tf==1.14.0
?
My datasets are audio files around 3000 files.
**filenames = tf.io.gfile.glob(str(data_dir) + '/*/*')
filenames = tf.random.shuffle(filenames)
num_samples = len(filenames)
print('Number of total examples:', num_samples)
print('Number of examples per label:',
len(tf.io.gfile.listdir(str(data_dir/commands[0]))))
print('Example file tensor:', filenames[0])**
Upvotes: 1
Views: 3325
Reputation: 599
len()
might not be supported for a Tensor for Tensorflow version 1.14.0. Use .shape
instead.
num_samples = filenames.shape[0]
.
Upvotes: 1