I am converting the embedding from the last fully connected layer of a CNN model into a numpy array. Currently, the embedding is a variable tensor which is not constant. I am wondering how to convert it into the numpy array as well.
Asked
Active
Viewed 605 times
0
-
There is always a message saying InvalidArgumentError: You must feed a value for placeholder tensor 'Placeholder' with dtype float [[Node: Placeholder = Placeholder[dtype=DT_FLOAT, shape=
, _device="/job:localhost/replica:0/task:0/device:GPU:0"]()]] – foresterhema Jul 23 '18 at 04:28
1 Answers
0
You should assign the tensor value to a variable within the session! Something like this. This is for taking out the bottleneck values from inception. Hope this helps.
with tf.Session(graph=graph) as sess:
im_input = graph.get_tensor_by_name('inception/ExpandDims:0')
Bottle_neck_values = []
m = train.shape[0]
indices = np.arange(m)
for index in tqdm(range(0, m, 1)):
batch = indices[index:index + 1]
Bottle_neck_values.append(sess.run(bottleneck, feed_dict=
{im_input:train[batch]}))
df = pd.DataFrame(np.array(np.squeeze(Bottle_neck_values)))
df.to_csv("./bottleneck/Bottle_neck_values.csv", index=False)

midhun pk
- 11
- 1