I'm struggling to convert a simple Keras tensor into a Numpy array. This is the code I want to perform:
input = tf.keras.Input(shape=(100, 1), name='input')
inputs = np.array(input)
Error: Cannot convert a symbolic Keras input/output to a numpy array.
First things first. Your input
is not a tensor, but a symbolic tensor.
More can be found in this answer
Now, coming back to answer your question. You need to convert the symbolic tensor to a tensor by first feeding the network with the data. Once you have the tensor, then you can proceed to get the numpy array out of it.
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.