|
4 | 4 |
|
5 | 5 | namespace Tensorflow |
6 | 6 | { |
7 | | - public class embedding_ops |
| 7 | + public class embedding_ops : Python |
8 | 8 | { |
9 | | - public Tensor _embedding_lookup_and_transform() |
| 9 | + /// <summary> |
| 10 | + /// Helper function for embedding_lookup and _compute_sampled_logits. |
| 11 | + /// </summary> |
| 12 | + /// <param name="params"></param> |
| 13 | + /// <param name="ids"></param> |
| 14 | + /// <param name="partition_strategy"></param> |
| 15 | + /// <param name="name"></param> |
| 16 | + /// <returns></returns> |
| 17 | + public static Tensor _embedding_lookup_and_transform(RefVariable @params, |
| 18 | + Tensor ids, |
| 19 | + string partition_strategy = "mod", |
| 20 | + string name = null, |
| 21 | + string max_norm = null) |
10 | 22 | { |
11 | | - throw new NotImplementedException(""); |
| 23 | + return with(new ops.name_scope(name, "embedding_lookup", new { @params, ids }), scope => |
| 24 | + { |
| 25 | + name = scope; |
| 26 | + int np = 1; |
| 27 | + ids = ops.convert_to_tensor(ids, name: "ids"); |
| 28 | + if(np == 1) |
| 29 | + { |
| 30 | + var gather = array_ops.gather(@params, ids, name: name); |
| 31 | + var result = _clip(@params, ids, max_norm); |
| 32 | + |
| 33 | + return array_ops.identity(result); |
| 34 | + } |
| 35 | + |
| 36 | + throw new NotImplementedException("_embedding_lookup_and_transform"); |
| 37 | + }); |
| 38 | + } |
| 39 | + |
| 40 | + public static Tensor _clip(RefVariable @params, Tensor ids, string max_norm = null) |
| 41 | + { |
| 42 | + if (max_norm == null) |
| 43 | + return @params; |
| 44 | + |
| 45 | + throw new NotImplementedException("_clip"); |
12 | 46 | } |
13 | 47 | } |
14 | 48 | } |
0 commit comments