| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a942564 commit bbc2e98
16 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -64,6 +64,9 @@ public Tensor substr(Tensor input, int pos, int len, | |||
| 64 | 64 | public Tensor substr(string input, int pos, int len, | |
| 65 | 65 | string name = null, string @uint = "BYTE") | |
| 66 | 66 | => ops.substr(input, pos, len, @uint: @uint, name: name); | |
| 67 | + | ||
| 68 | + public Tensor split(Tensor input, string sep = "", int maxsplit = -1, string name = null) | ||
| 69 | + => ops.string_split_v2(input, sep: sep, maxsplit : maxsplit, name : name); | ||
| 67 | 70 | } | |
| 68 | 71 | } | |
| 69 | 72 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -68,6 +68,17 @@ public IDatasetV2 map(Func<Tensors, Tensors> map_func, | |||
| 68 | 68 | public IDatasetV2 map(Func<Tensors, Tensors> map_func, int num_parallel_calls) | |
| 69 | 69 | => new ParallelMapDataset(this, map_func, num_parallel_calls: num_parallel_calls); | |
| 70 | 70 | ||
| 71 | + public OwnedIterator make_one_shot_iterator() | ||
| 72 | + { | ||
| 73 | + if (tf.Context.executing_eagerly()) | ||
| 74 | + { | ||
| 75 | + // with ops.colocate_with(self._variant_tensor) | ||
| 76 | + return new OwnedIterator(this); | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + throw new NotImplementedException(""); | ||
| 80 | + } | ||
| 81 | + | ||
| 71 | 82 | public IDatasetV2 flat_map(Func<Tensor, IDatasetV2> map_func) | |
| 72 | 83 | => new FlatMapDataset(this, map_func); | |
| 73 | 84 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -72,6 +72,8 @@ IDatasetV2 map(Func<Tensors, Tensors> map_func, | |||
| 72 | 72 | IDatasetV2 map(Func<Tensors, Tensors> map_func, | |
| 73 | 73 | int num_parallel_calls); | |
| 74 | 74 | ||
| 75 | + OwnedIterator make_one_shot_iterator(); | ||
| 76 | + | ||
| 75 | 77 | IDatasetV2 flat_map(Func<Tensor, IDatasetV2> map_func); | |
| 76 | 78 | ||
| 77 | 79 | IDatasetV2 model(AutotuneAlgorithm algorithm, long cpu_budget); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -26,6 +26,7 @@ void _create_iterator(IDatasetV2 dataset) | |||
| 26 | 26 | dataset = dataset.apply_options(); | |
| 27 | 27 | _dataset = dataset; | |
| 28 | 28 | _element_spec = dataset.element_spec; | |
| 29 | + // _flat_output_types = | ||
| 29 | 30 | (_iterator_resource, _deleter) = ops.anonymous_iterator_v2(_dataset.output_types, _dataset.output_shapes); | |
| 30 | 31 | ops.make_iterator(dataset.variant_tensor, _iterator_resource); | |
| 31 | 32 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,5 +11,6 @@ public class TextVectorizationArgs : PreprocessingLayerArgs | |||
| 11 | 11 | public int MaxTokens { get; set; } = -1; | |
| 12 | 12 | public string OutputMode { get; set; } = "int"; | |
| 13 | 13 | public int OutputSequenceLength { get; set; } = -1; | |
| 14 | + public string[] Vocabulary { get; set; } | ||
| 14 | 15 | } | |
| 15 | 16 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -41,5 +41,10 @@ public Tensor substr<T>(T input, int pos, int len, | |||
| 41 | 41 | string @uint = "BYTE", string name = null) | |
| 42 | 42 | => tf.Context.ExecuteOp("Substr", name, new ExecuteOpArgs(input, pos, len) | |
| 43 | 43 | .SetAttributes(new { unit = @uint })); | |
| 44 | + | ||
| 45 | + public Tensor string_split_v2(Tensor input, string sep = "", int maxsplit = -1, string name = null) | ||
| 46 | + { | ||
| 47 | + return null; | ||
| 48 | + } | ||
| 44 | 49 | } | |
| 45 | 50 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,11 +8,23 @@ namespace Tensorflow.Keras.Engine | |||
| 8 | 8 | public class CombinerPreprocessingLayer : Layer | |
| 9 | 9 | { | |
| 10 | 10 | PreprocessingLayerArgs args; | |
| 11 | + protected ICombiner combiner; | ||
| 12 | + protected bool _previously_updated; | ||
| 11 | 13 | ||
| 12 | 14 | public CombinerPreprocessingLayer(PreprocessingLayerArgs args) | |
| 13 | 15 | : base(args) | |
| 14 | 16 | { | |
| 15 | - | ||
| 17 | + _previously_updated = false; | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + public virtual void adapt(IDatasetV2 data, bool reset_state = true) | ||
| 21 | + { | ||
| 22 | + IAccumulator accumulator; | ||
| 23 | + if (!reset_state) | ||
| 24 | + accumulator = combiner.Restore(); | ||
| 25 | + | ||
| 26 | + var next_data = data.make_one_shot_iterator(); | ||
| 27 | + var data_element = next_data.next(); | ||
| 16 | 28 | } | |
| 17 | 29 | } | |
| 18 | 30 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,10 @@ | |||
| 1 | + using System; | ||
| 2 | + using System.Collections.Generic; | ||
| 3 | + using System.Text; | ||
| 4 | + | ||
| 5 | + namespace Tensorflow.Keras.Engine | ||
| 6 | + { | ||
| 7 | + public interface IAccumulator | ||
| 8 | + { | ||
| 9 | + } | ||
| 10 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,19 @@ | |||
| 1 | + using System; | ||
| 2 | + using System.Collections.Generic; | ||
| 3 | + using System.Text; | ||
| 4 | + | ||
| 5 | + namespace Tensorflow.Keras.Engine | ||
| 6 | + { | ||
| 7 | + /// <summary> | ||
| 8 | + /// Functional object that defines a shardable computation. | ||
| 9 | + /// </summary> | ||
| 10 | + public interface ICombiner | ||
| 11 | + { | ||
| 12 | + void Compute(Tensor values, IAccumulator accumulator = null); | ||
| 13 | + void Merge(); | ||
| 14 | + void Extract(); | ||
| 15 | + IAccumulator Restore(); | ||
| 16 | + void Serialize(); | ||
| 17 | + void Deserialize(); | ||
| 18 | + } | ||
| 19 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,30 @@ | |||
| 1 | + using System; | ||
| 2 | + using System.Collections.Generic; | ||
| 3 | + using System.Text; | ||
| 4 | + using Tensorflow.Keras.ArgsDefinition; | ||
| 5 | + using Tensorflow.Keras.Engine; | ||
| 6 | + | ||
| 7 | + namespace Tensorflow.Keras.Layers | ||
| 8 | + { | ||
| 9 | + public class IndexLookup : CombinerPreprocessingLayer | ||
| 10 | + { | ||
| 11 | + public IndexLookup(int max_tokens = -1, | ||
| 12 | + int num_oov_indices = 1, | ||
| 13 | + string mask_token = "", | ||
| 14 | + string oov_token = "[UNK]", | ||
| 15 | + string encoding = "utf-8", | ||
| 16 | + bool invert = false) : base(new PreprocessingLayerArgs()) | ||
| 17 | + { | ||
| 18 | + var num_mask_tokens = mask_token == null ? 0 : 1; | ||
| 19 | + var vocab_size = max_tokens - (num_oov_indices + num_mask_tokens); | ||
| 20 | + combiner = new IndexLookupCombiner(vocab_size, mask_token); | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + public override void adapt(IDatasetV2 data, bool reset_state = true) | ||
| 24 | + { | ||
| 25 | + if (!reset_state) | ||
| 26 | + throw new ValueError("IndexLookup does not support streaming adapts."); | ||
| 27 | + base.adapt(data, reset_state); | ||
| 28 | + } | ||
| 29 | + } | ||
| 30 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments