NotImplementedError: Cannot convert a symbolic Tensor (TensorArrayV2Read/TensorListGetItem:0) to a numpy array.

119 views
Skip to first unread message

Mehadi Hasan Menon

unread,
Apr 28, 2020, 11:39:45 AM4/28/20
to TensorFlow Developers
Hello, When I run "padd_spectrograms" method using "@tf.function" I'm getting "Cannot convert a symbolic Tensor" error
what could be the cause

@tf.function
def padd_spectrograms(spectogram, padd_len):
    t
= tf.transpose(spectogram) # feature x timestep -> timestep x feature
    p
= tf.keras.preprocessing.sequence.pad_sequences(
        t
, maxlen=padd_len, dtype='float32', padding='post', truncating='post')
   
return tf.transpose(p) # back to feature x timestep


signals
= get_audio_data('data/audios/00a1e54507.flac')
spectograms
= get_spectrograms(signals)
# print('spectogram shape:', spectograms.shape)
padd_spect
= padd_spectrograms(spectograms, spectograms.shape[0])


V Deamo

unread,
Apr 28, 2020, 9:52:47 PM4/28/20
to TensorFlow Developers
Hi, there,

The problem occurred because of the `tf.transpose` api, this is the version alias to `tf.compat.v1`. You can place tf.transpose outside the `@tf.function`, or change `tf.transpose` to `tf.keras.backend.transpose` instead. This is confirmed to solve this problem under TF2.1.

Vincent

在 2020年4月28日星期二 UTC+8下午11:39:45,Mehadi Hasan Menon写道:

Mehadi Hasan Menon

unread,
Apr 28, 2020, 11:30:45 PM4/28/20
to TensorFlow Developers
Hi,

I replace
tf.transpose(spectogram)
by
tf.keras.backend.transpose(spectogram)

But still have the same issue.

I'm using the tensorflow 2.1

Thanks
Reply all
Reply to author
Forward
0 new messages