Skip to content

Commit 5f595eb

Browse files
committed
feed_dict_tensor in BaseSession._run
1 parent 2995c36 commit 5f595eb

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

src/TensorFlowNET.Core/BaseSession.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System;
1+
using NumSharp.Core;
2+
using System;
23
using System.Collections.Generic;
34
using System.Text;
45

@@ -44,6 +45,24 @@ public virtual byte[] run(Tensor fetches, Dictionary<Tensor, object> feed_dict =
4445

4546
private unsafe byte[] _run(Tensor fetches, Dictionary<Tensor, object> feed_dict = null)
4647
{
48+
var feed_dict_tensor = new Dictionary<Tensor, NDArray>();
49+
50+
if (feed_dict != null)
51+
{
52+
NDArray np_val = null;
53+
foreach (var feed in feed_dict)
54+
{
55+
switch (feed.Value)
56+
{
57+
case float value:
58+
np_val = np.asarray(value);
59+
break;
60+
}
61+
62+
feed_dict_tensor[feed.Key] = np_val;
63+
}
64+
}
65+
4766
var status = new Status();
4867

4968
c_api.TF_SessionRun(_session,

src/TensorFlowNET.Core/Tensor.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ public class Tensor
1313
private DataType _dtype;
1414
public DataType dtype => _dtype;
1515

16+
public string name;
17+
1618
public Tensor(Operation op, int value_index, DataType dtype)
1719
{
1820
_op = op;

0 commit comments

Comments
 (0)