FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

added tf.concat interface. · attackgithub/TensorFlow.NET@112247f · GitHub

Repository navigation

Commit 112247f

Browse files
committed
added tf.concat interface.
1 parent f0d1ee8 commit 112247f

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

‎src/TensorFlowNET.Core/APIs/tf.array.cs‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Linq;
34
using System.Text;
45

56
namespace Tensorflow
67
{
78
public static partial class tf
89
{
10+
/// <summary>
11+
/// Concatenates tensors along one dimension.
12+
/// </summary>
13+
/// <param name="values">A list of `Tensor` objects or a single `Tensor`.</param>
14+
/// <param name="axis"></param>
15+
/// <param name="name"></param>
16+
/// <returns>A `Tensor` resulting from concatenation of the input tensors.</returns>
17+
public static Tensor concat(IList<Tensor> values, int axis, string name = "concat")
18+
{
19+
if (values.Count == 1)
20+
throw new NotImplementedException("tf.concat length is 1");
21+
22+
return gen_array_ops.concat_v2(values.ToArray(), axis, name: name);
23+
}
24+
925
/// <summary>
1026
/// Inserts a dimension of 1 into a tensor's shape.
1127
/// </summary>

‎test/TensorFlowNET.Examples/TextProcess/CnnTextClassification.cs‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,14 @@ public Graph BuildGraph()
195195
pooled_outputs.Add(pool);
196196
}
197197

198-
// var h_pool = tf.concat(pooled_outputs, 3);
198+
var h_pool = tf.concat(pooled_outputs, 3);
199+
var h_pool_flat = tf.reshape(h_pool, new TensorShape(-1, num_filters * filter_sizes.Rank));
200+
201+
with(tf.name_scope("dropout"), delegate
202+
{
203+
// var h_drop = tf.nn.dropout(h_pool_flat, self.keep_prob);
204+
});
205+
199206
return graph;
200207
}
201208

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL