Rahul Anand
Rahul Anand

Reputation: 437

How to find output instead of dimensions in keras?

I tried to get the output of following code, instead of output I get the dimension of variable.

I have gone through google search but I got nothing related to it.

a=np.array([1,2,3])
b=np.array([4,5,6])
c=np.array([7,8,9])
a = keras.backend.variable(a)
b = keras.backend.variable(b)
c = keras.backend.variable(c)
merged_vector = concatenate([a,b,c], axis=-1)
print(merged_vector)

Here is the output I get instead of value stored in "merged_vector."

"Tensor("concatenate_2/concat:0", shape=(9,), dtype=float32)"

Upvotes: 0

Views: 57

Answers (1)

dallonsi
dallonsi

Reputation: 1526

For that, use get_value:

import numpy as np
import keras
from keras.layers import concatenate
import tensorflow as tf

a=np.array([1,2,3])
b=np.array([4,5,6])
c=np.array([7,8,9])
a = keras.backend.variable(a)
b = keras.backend.variable(b)
c = keras.backend.variable(c)
merged_vector = concatenate([a,b,c], axis=-1)
print(keras.backend.get_value(merged_vector))

Upvotes: 3

Related Questions