| @@ -2,18 +2,23 @@ | |||||
| using OneOf; | using OneOf; | ||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| <<<<<<< HEAD | |||||
| using Tensorflow.Keras.Layers.Rnn; | using Tensorflow.Keras.Layers.Rnn; | ||||
| ======= | ======= | ||||
| using Tensorflow.Keras.Layers; | using Tensorflow.Keras.Layers; | ||||
| using Tensorflow.Keras.ArgsDefinition.Rnn; | using Tensorflow.Keras.ArgsDefinition.Rnn; | ||||
| using Tensorflow.NumPy; | using Tensorflow.NumPy; | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| using Tensorflow.Keras.Layers.Rnn; | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| namespace Tensorflow.Keras.ArgsDefinition.Rnn | namespace Tensorflow.Keras.ArgsDefinition.Rnn | ||||
| { | { | ||||
| // TODO(Rinne): add regularizers. | // TODO(Rinne): add regularizers. | ||||
| public class RNNArgs : AutoSerializeLayerArgs | public class RNNArgs : AutoSerializeLayerArgs | ||||
| { | { | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| [JsonProperty("cell")] | [JsonProperty("cell")] | ||||
| // TODO: the cell should be serialized with `serialize_keras_object`. | // TODO: the cell should be serialized with `serialize_keras_object`. | ||||
| @@ -31,6 +36,13 @@ namespace Tensorflow.Keras.ArgsDefinition.Rnn | |||||
| // TODO: the cell should be serialized with `serialize_keras_object`. | // TODO: the cell should be serialized with `serialize_keras_object`. | ||||
| public OneOf<IList<IRnnArgCell>, IRnnArgCell> Cell { get; set; } | public OneOf<IList<IRnnArgCell>, IRnnArgCell> Cell { get; set; } | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| [JsonProperty("cell")] | |||||
| // TODO: the cell should be serialized with `serialize_keras_object`. | |||||
| public IRnnCell Cell { get; set; } = null; | |||||
| [JsonProperty("cells")] | |||||
| public IList<IRnnCell> Cells { get; set; } = null; | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| [JsonProperty("return_sequences")] | [JsonProperty("return_sequences")] | ||||
| public bool ReturnSequences { get; set; } = false; | public bool ReturnSequences { get; set; } = false; | ||||
| @@ -1,19 +1,27 @@ | |||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| <<<<<<< HEAD | |||||
| using Tensorflow.Keras.Layers.Rnn; | using Tensorflow.Keras.Layers.Rnn; | ||||
| ======= | ======= | ||||
| using static Tensorflow.Keras.ArgsDefinition.Rnn.RNNArgs; | using static Tensorflow.Keras.ArgsDefinition.Rnn.RNNArgs; | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| using Tensorflow.Keras.Layers.Rnn; | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| namespace Tensorflow.Keras.ArgsDefinition.Rnn | namespace Tensorflow.Keras.ArgsDefinition.Rnn | ||||
| { | { | ||||
| public class StackedRNNCellsArgs : LayerArgs | public class StackedRNNCellsArgs : LayerArgs | ||||
| { | { | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| public IList<IRnnCell> Cells { get; set; } | public IList<IRnnCell> Cells { get; set; } | ||||
| ======= | ======= | ||||
| public IList<IRnnArgCell> Cells { get; set; } | public IList<IRnnArgCell> Cells { get; set; } | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| public IList<IRnnCell> Cells { get; set; } | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| public Dictionary<string, object> Kwargs { get; set; } = null; | public Dictionary<string, object> Kwargs { get; set; } = null; | ||||
| } | } | ||||
| } | } | ||||
| @@ -227,6 +227,9 @@ namespace Tensorflow.Keras.Layers | |||||
| bool return_state = false); | bool return_state = false); | ||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| <<<<<<< HEAD | |||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| public ILayer RNN( | public ILayer RNN( | ||||
| IRnnCell cell, | IRnnCell cell, | ||||
| bool return_sequences = false, | bool return_sequences = false, | ||||
| @@ -246,6 +249,7 @@ namespace Tensorflow.Keras.Layers | |||||
| bool unroll = false, | bool unroll = false, | ||||
| bool time_major = false | bool time_major = false | ||||
| ); | ); | ||||
| <<<<<<< HEAD | |||||
| ======= | ======= | ||||
| public ILayer SimpleRNNCell( | public ILayer SimpleRNNCell( | ||||
| int units, | int units, | ||||
| @@ -257,6 +261,8 @@ namespace Tensorflow.Keras.Layers | |||||
| float dropout = 0f, | float dropout = 0f, | ||||
| float recurrent_dropout = 0f); | float recurrent_dropout = 0f); | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| public ILayer Subtract(); | public ILayer Subtract(); | ||||
| } | } | ||||
| @@ -53,12 +53,17 @@ namespace Tensorflow | |||||
| /// matching structure of Tensors having shape `[batch_size].concatenate(s)` | /// matching structure of Tensors having shape `[batch_size].concatenate(s)` | ||||
| /// for each `s` in `self.batch_size`. | /// for each `s` in `self.batch_size`. | ||||
| /// </summary> | /// </summary> | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| [Obsolete("This is an incompleted tf v1 api, pleas use keras RNNs instead.")] | [Obsolete("This is an incompleted tf v1 api, pleas use keras RNNs instead.")] | ||||
| public abstract class RnnCell : ILayer, IRnnCell | public abstract class RnnCell : ILayer, IRnnCell | ||||
| ======= | ======= | ||||
| public abstract class RnnCell : ILayer | public abstract class RnnCell : ILayer | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| [Obsolete("This is an incompleted tf v1 api, pleas use keras RNNs instead.")] | |||||
| public abstract class RnnCell : ILayer, IRnnCell | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| /// <summary> | /// <summary> | ||||
| /// Attribute that indicates whether the cell is a TF RNN cell, due the slight | /// Attribute that indicates whether the cell is a TF RNN cell, due the slight | ||||
| @@ -185,6 +190,9 @@ namespace Tensorflow | |||||
| } | } | ||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| <<<<<<< HEAD | |||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| public (Tensor, Tensors) Call(Tensors inputs, Tensors states, bool? training = null) | public (Tensor, Tensors) Call(Tensors inputs, Tensors states, bool? training = null) | ||||
| { | { | ||||
| throw new NotImplementedException(); | throw new NotImplementedException(); | ||||
| @@ -193,11 +201,14 @@ namespace Tensorflow | |||||
| public GeneralizedTensorShape OutputSize => throw new NotImplementedException(); | public GeneralizedTensorShape OutputSize => throw new NotImplementedException(); | ||||
| public bool IsTFRnnCell => throw new NotImplementedException(); | public bool IsTFRnnCell => throw new NotImplementedException(); | ||||
| public bool SupportOptionalArgs => throw new NotImplementedException(); | public bool SupportOptionalArgs => throw new NotImplementedException(); | ||||
| <<<<<<< HEAD | |||||
| ======= | ======= | ||||
| public Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | public Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| { | { | ||||
| throw new NotImplementedException(); | throw new NotImplementedException(); | ||||
| } | } | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| } | } | ||||
| } | } | ||||
| @@ -25,11 +25,15 @@ using static Tensorflow.Binding; | |||||
| using static Tensorflow.Graphs.SubGraphUtility; | using static Tensorflow.Graphs.SubGraphUtility; | ||||
| using Tensorflow.Util; | using Tensorflow.Util; | ||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| <<<<<<< HEAD | |||||
| using Tensorflow.Common.Types; | using Tensorflow.Common.Types; | ||||
| ======= | ======= | ||||
| using Tensorflow.Operations; | using Tensorflow.Operations; | ||||
| using OneOf; | using OneOf; | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| using Tensorflow.Common.Types; | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| namespace Tensorflow.Keras | namespace Tensorflow.Keras | ||||
| { | { | ||||
| @@ -460,6 +464,9 @@ namespace Tensorflow.Keras | |||||
| } | } | ||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| <<<<<<< HEAD | |||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| public (Tensors, Tensors, Tensors) rnn( | public (Tensors, Tensors, Tensors) rnn( | ||||
| Func<Tensors, Tensors, (Tensors, Tensors)> step_function, // args:inputs, states, return:output, new_states | Func<Tensors, Tensors, (Tensors, Tensors)> step_function, // args:inputs, states, return:output, new_states | ||||
| Tensors inputs, // inputs is a tuple of tensors (one per input sequence) | Tensors inputs, // inputs is a tuple of tensors (one per input sequence) | ||||
| @@ -475,6 +482,7 @@ namespace Tensorflow.Keras | |||||
| { | { | ||||
| Tensor swap_batch_timestep(Tensor input_t) | Tensor swap_batch_timestep(Tensor input_t) | ||||
| <<<<<<< HEAD | |||||
| ======= | ======= | ||||
| public static (Tensors, Tensors) convert_inputs_if_ragged(OneOf<Tensor, RaggedTensor> inputs) | public static (Tensors, Tensors) convert_inputs_if_ragged(OneOf<Tensor, RaggedTensor> inputs) | ||||
| { | { | ||||
| @@ -498,6 +506,8 @@ namespace Tensorflow.Keras | |||||
| Tensors swap_batch_timestep(Tensors input_t) | Tensors swap_batch_timestep(Tensors input_t) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| var axes = Enumerable.Range(0, input_t.rank).ToArray(); | var axes = Enumerable.Range(0, input_t.rank).ToArray(); | ||||
| axes[0] = 1; | axes[0] = 1; | ||||
| @@ -508,6 +518,9 @@ namespace Tensorflow.Keras | |||||
| if (!time_major) | if (!time_major) | ||||
| { | { | ||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| <<<<<<< HEAD | |||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| inputs = Nest.MapStructure(swap_batch_timestep, inputs).ToTensors(); | inputs = Nest.MapStructure(swap_batch_timestep, inputs).ToTensors(); | ||||
| } | } | ||||
| @@ -516,6 +529,7 @@ namespace Tensorflow.Keras | |||||
| var time_steps = first_flatted_input.shape[0]; | var time_steps = first_flatted_input.shape[0]; | ||||
| var batch = first_flatted_input.shape[1]; | var batch = first_flatted_input.shape[1]; | ||||
| var time_steps_t = (int)first_flatted_input.shape[0]; | var time_steps_t = (int)first_flatted_input.shape[0]; | ||||
| <<<<<<< HEAD | |||||
| ======= | ======= | ||||
| inputs = nest.map_structure(swap_batch_timestep, inputs); | inputs = nest.map_structure(swap_batch_timestep, inputs); | ||||
| } | } | ||||
| @@ -525,6 +539,8 @@ namespace Tensorflow.Keras | |||||
| var batch = flatted_inptus[0].shape[1]; | var batch = flatted_inptus[0].shape[1]; | ||||
| var time_step_t = tf.shape(flatted_inptus[0])[0]; | var time_step_t = tf.shape(flatted_inptus[0])[0]; | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| foreach (var input_ in flatted_inptus) | foreach (var input_ in flatted_inptus) | ||||
| { | { | ||||
| @@ -550,6 +566,7 @@ namespace Tensorflow.Keras | |||||
| } | } | ||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| <<<<<<< HEAD | |||||
| ======= | ======= | ||||
| @@ -559,6 +576,9 @@ namespace Tensorflow.Keras | |||||
| } | } | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| // tf.where needs its condition tensor to be the same shape as its two | // tf.where needs its condition tensor to be the same shape as its two | ||||
| // result tensors, but in our case the condition (mask) tensor is | // result tensors, but in our case the condition (mask) tensor is | ||||
| // (nsamples, 1), and inputs are (nsamples, ndimensions) or even more. | // (nsamples, 1), and inputs are (nsamples, ndimensions) or even more. | ||||
| @@ -568,20 +588,28 @@ namespace Tensorflow.Keras | |||||
| Tensors _expand_mask(Tensors mask_t, Tensors input_t, int fixed_dim = 1) | Tensors _expand_mask(Tensors mask_t, Tensors input_t, int fixed_dim = 1) | ||||
| { | { | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| if (!mask_t.IsSingle()) | if (!mask_t.IsSingle()) | ||||
| ======= | ======= | ||||
| if (nest.is_nested(mask_t)) | if (nest.is_nested(mask_t)) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| if (!mask_t.IsSingle()) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| throw new ValueError($"mask_t is expected to be tensor, but got {mask_t}"); | throw new ValueError($"mask_t is expected to be tensor, but got {mask_t}"); | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| if (!input_t.IsSingle()) | if (!input_t.IsSingle()) | ||||
| ======= | ======= | ||||
| if (nest.is_nested(input_t)) | if (nest.is_nested(input_t)) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| if (!input_t.IsSingle()) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| throw new ValueError($"input_t is expected to be tensor, but got {input_t}"); | throw new ValueError($"input_t is expected to be tensor, but got {input_t}"); | ||||
| } | } | ||||
| @@ -591,11 +619,15 @@ namespace Tensorflow.Keras | |||||
| { | { | ||||
| mask_t = tf.expand_dims(mask_t, -1); | mask_t = tf.expand_dims(mask_t, -1); | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| var multiples = Enumerable.Repeat(1, fixed_dim).ToArray().concat(input_t.shape.as_int_list().Skip(fixed_dim).ToArray()); | var multiples = Enumerable.Repeat(1, fixed_dim).ToArray().concat(input_t.shape.as_int_list().Skip(fixed_dim).ToArray()); | ||||
| ======= | ======= | ||||
| var multiples = Enumerable.Repeat(1, fixed_dim).ToArray().concat(input_t.shape.as_int_list().ToList().GetRange(fixed_dim, input_t.rank)); | var multiples = Enumerable.Repeat(1, fixed_dim).ToArray().concat(input_t.shape.as_int_list().ToList().GetRange(fixed_dim, input_t.rank)); | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| var multiples = Enumerable.Repeat(1, fixed_dim).ToArray().concat(input_t.shape.as_int_list().Skip(fixed_dim).ToArray()); | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| return tf.tile(mask_t, multiples); | return tf.tile(mask_t, multiples); | ||||
| } | } | ||||
| @@ -631,6 +663,9 @@ namespace Tensorflow.Keras | |||||
| // the item in tuple is list of the tensor with shape (batch, feature) | // the item in tuple is list of the tensor with shape (batch, feature) | ||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| <<<<<<< HEAD | |||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| Tensors _process_single_input_t(Tensor input_t) | Tensors _process_single_input_t(Tensor input_t) | ||||
| { | { | ||||
| var unstaked_input_t = array_ops.unstack(input_t); // unstack for time_step dim | var unstaked_input_t = array_ops.unstack(input_t); // unstack for time_step dim | ||||
| @@ -639,6 +674,7 @@ namespace Tensorflow.Keras | |||||
| unstaked_input_t = unstaked_input_t.Reverse().ToArray(); | unstaked_input_t = unstaked_input_t.Reverse().ToArray(); | ||||
| } | } | ||||
| return unstaked_input_t; | return unstaked_input_t; | ||||
| <<<<<<< HEAD | |||||
| ======= | ======= | ||||
| @@ -652,10 +688,13 @@ namespace Tensorflow.Keras | |||||
| } | } | ||||
| return input_t; | return input_t; | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| } | } | ||||
| // TODO(Wanglongzhi2001) | // TODO(Wanglongzhi2001) | ||||
| Tensors processed_input; | Tensors processed_input; | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| if (!inputs.IsSingle()) | if (!inputs.IsSingle()) | ||||
| { | { | ||||
| @@ -665,6 +704,11 @@ namespace Tensorflow.Keras | |||||
| { | { | ||||
| processed_input = nest.map_structure(_process_single_input_t, inputs); | processed_input = nest.map_structure(_process_single_input_t, inputs); | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| if (!inputs.IsSingle()) | |||||
| { | |||||
| processed_input = inputs.MapStructure(_process_single_input_t).ReduceTo<Tensors, Tensor>().ToTensors(); | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -679,6 +723,9 @@ namespace Tensorflow.Keras | |||||
| inp.Add(t_[time]); | inp.Add(t_[time]); | ||||
| } | } | ||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| <<<<<<< HEAD | |||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| return Nest.PackSequenceAs(inputs, inp); | return Nest.PackSequenceAs(inputs, inp); | ||||
| } | } | ||||
| @@ -1006,6 +1053,7 @@ namespace Tensorflow.Keras | |||||
| last_output = Nest.PackSequenceAs(output_time_zero, last_output).ToTensors(); | last_output = Nest.PackSequenceAs(output_time_zero, last_output).ToTensors(); | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| ======= | ======= | ||||
| return nest.pack_sequence_as(inputs, inp); | return nest.pack_sequence_as(inputs, inp); | ||||
| } | } | ||||
| @@ -1336,6 +1384,8 @@ namespace Tensorflow.Keras | |||||
| //} | //} | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| Func<Tensor, Tensor> set_shape; | Func<Tensor, Tensor> set_shape; | ||||
| set_shape = (output_) => | set_shape = (output_) => | ||||
| @@ -1352,16 +1402,23 @@ namespace Tensorflow.Keras | |||||
| shape[0] = 1; | shape[0] = 1; | ||||
| } | } | ||||
| shape[1] = (int)batch; | shape[1] = (int)batch; | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| output_.shape = shape; | output_.shape = shape; | ||||
| ======= | ======= | ||||
| output_.set_shape(new Tensor(shape)); | output_.set_shape(new Tensor(shape)); | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| output_.shape = shape; | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| } | } | ||||
| return output_; | return output_; | ||||
| }; | }; | ||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| <<<<<<< HEAD | |||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| outputs = Nest.MapStructure(set_shape, outputs).ToTensors(); | outputs = Nest.MapStructure(set_shape, outputs).ToTensors(); | ||||
| if (!time_major) | if (!time_major) | ||||
| { | { | ||||
| @@ -1389,6 +1446,7 @@ namespace Tensorflow.Keras | |||||
| } | } | ||||
| throw new NotImplementedException("Not implemented currently, please submit an issue to https://github.com/SciSharp/TensorFlow.NET/issues"); | throw new NotImplementedException("Not implemented currently, please submit an issue to https://github.com/SciSharp/TensorFlow.NET/issues"); | ||||
| <<<<<<< HEAD | |||||
| ======= | ======= | ||||
| var Outputs = (Tensors)nest.map_structure(set_shape, outputs); | var Outputs = (Tensors)nest.map_structure(set_shape, outputs); | ||||
| if (!time_major) | if (!time_major) | ||||
| @@ -1420,6 +1478,8 @@ namespace Tensorflow.Keras | |||||
| //} | //} | ||||
| throw new NotImplementedException(); | throw new NotImplementedException(); | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -326,11 +326,15 @@ namespace Tensorflow.Keras.Engine | |||||
| nodes_in_decreasing_depth.append(node); | nodes_in_decreasing_depth.append(node); | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | ||||
| ======= | ======= | ||||
| protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| var tensor_dict = new Dictionary<long, Queue<Tensor>>(); | var tensor_dict = new Dictionary<long, Queue<Tensor>>(); | ||||
| // map input values | // map input values | ||||
| @@ -31,11 +31,15 @@ namespace Tensorflow.Keras.Engine | |||||
| if (!built) | if (!built) | ||||
| MaybeBuild(inputs); | MaybeBuild(inputs); | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| var outputs = Call(inputs, state: states, training: training); | var outputs = Call(inputs, state: states, training: training); | ||||
| ======= | ======= | ||||
| var outputs = Call(inputs, initial_state: state, training: training); | var outputs = Call(inputs, initial_state: state, training: training); | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| var outputs = Call(inputs, state: states, training: training); | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| // memory leak | // memory leak | ||||
| // _set_connectivity_metadata_(inputs, outputs); | // _set_connectivity_metadata_(inputs, outputs); | ||||
| @@ -336,11 +336,15 @@ namespace Tensorflow.Keras.Engine | |||||
| /// <param name="state"></param> | /// <param name="state"></param> | ||||
| /// <param name="training"></param> | /// <param name="training"></param> | ||||
| /// <returns></returns> | /// <returns></returns> | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected virtual Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | protected virtual Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | ||||
| ======= | ======= | ||||
| protected virtual Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | protected virtual Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected virtual Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| if (ReplacedCall is not null) | if (ReplacedCall is not null) | ||||
| { | { | ||||
| @@ -144,11 +144,15 @@ namespace Tensorflow.Keras.Engine | |||||
| } | } | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | ||||
| ======= | ======= | ||||
| protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| if (!_has_explicit_input_shape) | if (!_has_explicit_input_shape) | ||||
| { | { | ||||
| @@ -30,11 +30,15 @@ namespace Tensorflow.Keras.Layers { | |||||
| base.build(input_shape); | base.build(input_shape); | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | ||||
| ======= | ======= | ||||
| protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| Tensor output = inputs; | Tensor output = inputs; | ||||
| output = tf.where(output > 0f, output, | output = tf.where(output > 0f, output, | ||||
| @@ -17,11 +17,15 @@ namespace Tensorflow.Keras.Layers { | |||||
| { | { | ||||
| base.build(input_shape); | base.build(input_shape); | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | ||||
| ======= | ======= | ||||
| protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| Tensor output = inputs; | Tensor output = inputs; | ||||
| return tf.exp(output); | return tf.exp(output); | ||||
| @@ -11,12 +11,16 @@ namespace Tensorflow.Keras.Layers { | |||||
| public HardSigmoid ( LayerArgs args ) : base(args) { | public HardSigmoid ( LayerArgs args ) : base(args) { | ||||
| // hard sigmoid has no arguments | // hard sigmoid has no arguments | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call ( Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null ) { | protected override Tensors Call ( Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null ) { | ||||
| ======= | ======= | ||||
| protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| { | { | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call ( Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null ) { | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| Tensor x = inputs; | Tensor x = inputs; | ||||
| return tf.clip_by_value( | return tf.clip_by_value( | ||||
| tf.add(tf.multiply(x, 0.2f), 0.5f), 0f, 1f); | tf.add(tf.multiply(x, 0.2f), 0.5f), 0f, 1f); | ||||
| @@ -20,11 +20,15 @@ namespace Tensorflow.Keras.Layers | |||||
| this.args = args; | this.args = args; | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | ||||
| ======= | ======= | ||||
| protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| return tf.nn.leaky_relu(inputs, alpha: alpha); | return tf.nn.leaky_relu(inputs, alpha: alpha); | ||||
| } | } | ||||
| @@ -23,12 +23,16 @@ namespace Tensorflow.Keras.Layers { | |||||
| } | } | ||||
| base.build(input_shape); | base.build(input_shape); | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call ( Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) { | protected override Tensors Call ( Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) { | ||||
| ======= | ======= | ||||
| protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| { | { | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call ( Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) { | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| Tensor output = inputs; | Tensor output = inputs; | ||||
| return tf.where(output > 0f, | return tf.where(output > 0f, | ||||
| tf.multiply(scale, output), | tf.multiply(scale, output), | ||||
| @@ -12,6 +12,7 @@ namespace Tensorflow.Keras.Layers { | |||||
| public Softmax ( SoftmaxArgs args ) : base(args) { | public Softmax ( SoftmaxArgs args ) : base(args) { | ||||
| axis = args.axis; | axis = args.axis; | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call ( Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) { | protected override Tensors Call ( Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) { | ||||
| Tensor x = inputs.Length == 2 ? inputs[0] + ((1.0 - tf.cast(inputs[1], inputs.dtype)) * 1e-9) | Tensor x = inputs.Length == 2 ? inputs[0] + ((1.0 - tf.cast(inputs[1], inputs.dtype)) * 1e-9) | ||||
| @@ -20,6 +21,10 @@ namespace Tensorflow.Keras.Layers { | |||||
| { | { | ||||
| Tensor x = inputs.Length == 2 ? inputs + ((1.0 - tf.cast(inputs[1], inputs.dtype)) * 1e-9) | Tensor x = inputs.Length == 2 ? inputs + ((1.0 - tf.cast(inputs[1], inputs.dtype)) * 1e-9) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call ( Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) { | |||||
| Tensor x = inputs.Length == 2 ? inputs[0] + ((1.0 - tf.cast(inputs[1], inputs.dtype)) * 1e-9) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| : inputs; | : inputs; | ||||
| Tensor e = tf.exp(tf.sub(x, tf.reduce_max(x, axis: this.axis, keepdims: true))); | Tensor e = tf.exp(tf.sub(x, tf.reduce_max(x, axis: this.axis, keepdims: true))); | ||||
| Tensor s = tf.reduce_sum(e, axis: this.axis, keepdims: true); | Tensor s = tf.reduce_sum(e, axis: this.axis, keepdims: true); | ||||
| @@ -11,12 +11,16 @@ namespace Tensorflow.Keras.Layers { | |||||
| public Softplus ( LayerArgs args ) : base(args) { | public Softplus ( LayerArgs args ) : base(args) { | ||||
| // Softplus has no arguments | // Softplus has no arguments | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call ( Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) { | protected override Tensors Call ( Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) { | ||||
| ======= | ======= | ||||
| protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| { | { | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call ( Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) { | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| Tensor x = inputs; | Tensor x = inputs; | ||||
| return tf.log( | return tf.log( | ||||
| tf.add(tf.exp(x), 1f)); | tf.add(tf.exp(x), 1f)); | ||||
| @@ -11,12 +11,16 @@ namespace Tensorflow.Keras.Layers { | |||||
| public Softsign ( LayerArgs args ) : base(args) { | public Softsign ( LayerArgs args ) : base(args) { | ||||
| // Softsign has no arguments | // Softsign has no arguments | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call ( Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) { | protected override Tensors Call ( Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) { | ||||
| ======= | ======= | ||||
| protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| { | { | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call ( Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) { | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| Tensor x = inputs; | Tensor x = inputs; | ||||
| // x / (abs(x) + 1) | // x / (abs(x) + 1) | ||||
| return tf.div(x, tf.add(1f, tf.abs(x))); | return tf.div(x, tf.add(1f, tf.abs(x))); | ||||
| @@ -11,12 +11,16 @@ namespace Tensorflow.Keras.Layers { | |||||
| public Swish ( LayerArgs args ) : base(args) { | public Swish ( LayerArgs args ) : base(args) { | ||||
| // Swish has no arguments | // Swish has no arguments | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call ( Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) { | protected override Tensors Call ( Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) { | ||||
| ======= | ======= | ||||
| protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| { | { | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call ( Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) { | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| Tensor x = inputs; | Tensor x = inputs; | ||||
| // x / (1 + exp(-x)) | // x / (1 + exp(-x)) | ||||
| @@ -14,11 +14,15 @@ namespace Tensorflow.Keras.Layers | |||||
| { | { | ||||
| // Tanh has no arguments | // Tanh has no arguments | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | ||||
| ======= | ======= | ||||
| protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| Tensor x = inputs; | Tensor x = inputs; | ||||
| @@ -115,11 +115,15 @@ namespace Tensorflow.Keras.Layers | |||||
| return (tf.linalg.einsum("bij,bjk->bik", (weights, value)), weights); | return (tf.linalg.einsum("bij,bjk->bik", (weights, value)), weights); | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | ||||
| ======= | ======= | ||||
| protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| Tensors _inp; | Tensors _inp; | ||||
| Tensors _mask = null; | Tensors _mask = null; | ||||
| @@ -253,11 +253,15 @@ namespace Tensorflow.Keras.Layers | |||||
| return (attention_output, attention_scores); | return (attention_output, attention_scores); | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | ||||
| ======= | ======= | ||||
| protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| Tensors _inp; | Tensors _inp; | ||||
| Tensor _mask = null; | Tensor _mask = null; | ||||
| @@ -84,11 +84,15 @@ namespace Tensorflow.Keras.Layers | |||||
| _buildInputShape = input_shape; | _buildInputShape = input_shape; | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | ||||
| ======= | ======= | ||||
| protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| var inputs_shape = array_ops.shape(inputs); | var inputs_shape = array_ops.shape(inputs); | ||||
| var batch_size = inputs_shape[0]; | var batch_size = inputs_shape[0]; | ||||
| @@ -104,11 +104,15 @@ namespace Tensorflow.Keras.Layers | |||||
| _buildInputShape = input_shape; | _buildInputShape = input_shape; | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = false, IOptionalArgs? optional_args = null) | protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = false, IOptionalArgs? optional_args = null) | ||||
| ======= | ======= | ||||
| protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = false, IOptionalArgs? optional_args = null) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| var outputs = _convolution_op.Apply(inputs, kernel.AsTensor()); | var outputs = _convolution_op.Apply(inputs, kernel.AsTensor()); | ||||
| if (use_bias) | if (use_bias) | ||||
| @@ -70,11 +70,15 @@ namespace Tensorflow.Keras.Layers | |||||
| built = true; | built = true; | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | ||||
| ======= | ======= | ||||
| protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| Tensor outputs = null; | Tensor outputs = null; | ||||
| var rank = inputs.rank; | var rank = inputs.rank; | ||||
| @@ -190,11 +190,15 @@ namespace Tensorflow.Keras.Layers | |||||
| // return new dict(base_config.items().ToList() + config.items().ToList()); | // return new dict(base_config.items().ToList() + config.items().ToList()); | ||||
| //} | //} | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | ||||
| ======= | ======= | ||||
| protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| var ret = tf.linalg.einsum(this.equation, (inputs, this.kernel.AsTensor())); | var ret = tf.linalg.einsum(this.equation, (inputs, this.kernel.AsTensor())); | ||||
| if (this.bias != null) | if (this.bias != null) | ||||
| @@ -67,11 +67,15 @@ namespace Tensorflow.Keras.Layers | |||||
| _buildInputShape = input_shape; | _buildInputShape = input_shape; | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | ||||
| ======= | ======= | ||||
| protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| var dtype = inputs.dtype; | var dtype = inputs.dtype; | ||||
| if (dtype != tf.int32 && dtype != tf.int64) | if (dtype != tf.int32 && dtype != tf.int64) | ||||
| @@ -809,6 +809,82 @@ namespace Tensorflow.Keras.Layers | |||||
| }); | }); | ||||
| public IRnnCell LSTMCell(int uints, | |||||
| string activation = "tanh", | |||||
| string recurrent_activation = "sigmoid", | |||||
| bool use_bias = true, | |||||
| string kernel_initializer = "glorot_uniform", | |||||
| string recurrent_initializer = "orthogonal", // TODO(Wanglongzhi2001),glorot_uniform has not been developed. | |||||
| string bias_initializer = "zeros", | |||||
| bool unit_forget_bias = true, | |||||
| float dropout = 0f, | |||||
| float recurrent_dropout = 0f, | |||||
| int implementation = 2) | |||||
| => new LSTMCell(new LSTMCellArgs | |||||
| { | |||||
| Units = uints, | |||||
| Activation = keras.activations.GetActivationFromName(activation), | |||||
| RecurrentActivation = keras.activations.GetActivationFromName(recurrent_activation), | |||||
| UseBias = use_bias, | |||||
| KernelInitializer = GetInitializerByName(kernel_initializer), | |||||
| RecurrentInitializer = GetInitializerByName(recurrent_initializer), | |||||
| BiasInitializer = GetInitializerByName(bias_initializer), | |||||
| UnitForgetBias = unit_forget_bias, | |||||
| Dropout = dropout, | |||||
| RecurrentDropout = recurrent_dropout, | |||||
| Implementation = implementation | |||||
| }); | |||||
| /// <summary> | |||||
| /// | |||||
| /// </summary> | |||||
| /// <param name="cell"></param> | |||||
| /// <param name="return_sequences"></param> | |||||
| /// <param name="return_state"></param> | |||||
| /// <param name="go_backwards"></param> | |||||
| /// <param name="stateful"></param> | |||||
| /// <param name="unroll"></param> | |||||
| /// <param name="time_major"></param> | |||||
| /// <returns></returns> | |||||
| public ILayer RNN( | |||||
| IRnnCell cell, | |||||
| bool return_sequences = false, | |||||
| bool return_state = false, | |||||
| bool go_backwards = false, | |||||
| bool stateful = false, | |||||
| bool unroll = false, | |||||
| bool time_major = false) | |||||
| => new RNN(new RNNArgs | |||||
| { | |||||
| Cell = cell, | |||||
| ReturnSequences = return_sequences, | |||||
| ReturnState = return_state, | |||||
| GoBackwards = go_backwards, | |||||
| Stateful = stateful, | |||||
| Unroll = unroll, | |||||
| TimeMajor = time_major | |||||
| }); | |||||
| public ILayer RNN( | |||||
| IEnumerable<IRnnCell> cell, | |||||
| bool return_sequences = false, | |||||
| bool return_state = false, | |||||
| bool go_backwards = false, | |||||
| bool stateful = false, | |||||
| bool unroll = false, | |||||
| bool time_major = false) | |||||
| => new RNN(new RNNArgs | |||||
| { | |||||
| Cells = cell.ToList(), | |||||
| ReturnSequences = return_sequences, | |||||
| ReturnState = return_state, | |||||
| GoBackwards = go_backwards, | |||||
| Stateful = stateful, | |||||
| Unroll = unroll, | |||||
| TimeMajor = time_major | |||||
| }); | |||||
| public IRnnCell LSTMCell(int uints, | public IRnnCell LSTMCell(int uints, | ||||
| string activation = "tanh", | string activation = "tanh", | ||||
| string recurrent_activation = "sigmoid", | string recurrent_activation = "sigmoid", | ||||
| @@ -22,11 +22,15 @@ namespace Tensorflow.Keras.Layers | |||||
| _buildInputShape = input_shape; | _buildInputShape = input_shape; | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | ||||
| ======= | ======= | ||||
| protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| return _merge_function(inputs); | return _merge_function(inputs); | ||||
| } | } | ||||
| @@ -147,11 +147,15 @@ namespace Tensorflow.Keras.Layers | |||||
| return false; | return false; | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | ||||
| ======= | ======= | ||||
| protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| Tensor outputs = null; | Tensor outputs = null; | ||||
| var training_tensor = training == null | var training_tensor = training == null | ||||
| @@ -102,11 +102,15 @@ namespace Tensorflow.Keras.Layers | |||||
| return input_shape; | return input_shape; | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | ||||
| ======= | ======= | ||||
| protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| Tensor outputs = null; | Tensor outputs = null; | ||||
| var inputs_dtype = inputs.dtype.as_base_dtype(); | var inputs_dtype = inputs.dtype.as_base_dtype(); | ||||
| @@ -158,11 +158,15 @@ namespace Tensorflow.Keras.Layers | |||||
| base.adapt(data, batch_size: batch_size, steps: steps); | base.adapt(data, batch_size: batch_size, steps: steps); | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | ||||
| ======= | ======= | ||||
| protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| if (_args.Invert) | if (_args.Invert) | ||||
| { | { | ||||
| @@ -13,11 +13,15 @@ namespace Tensorflow.Keras.Layers | |||||
| { | { | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | ||||
| ======= | ======= | ||||
| protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| if (data_format == "channels_last") | if (data_format == "channels_last") | ||||
| return math_ops.reduce_mean(inputs, 1, false); | return math_ops.reduce_mean(inputs, 1, false); | ||||
| @@ -13,11 +13,15 @@ namespace Tensorflow.Keras.Layers | |||||
| { | { | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | ||||
| ======= | ======= | ||||
| protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| if (data_format == "channels_last") | if (data_format == "channels_last") | ||||
| return math_ops.reduce_mean(inputs, (1, 2), false); | return math_ops.reduce_mean(inputs, (1, 2), false); | ||||
| @@ -13,11 +13,15 @@ namespace Tensorflow.Keras.Layers | |||||
| { | { | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | ||||
| ======= | ======= | ||||
| protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| if (data_format == "channels_last") | if (data_format == "channels_last") | ||||
| return math_ops.reduce_max(inputs, 1, false); | return math_ops.reduce_max(inputs, 1, false); | ||||
| @@ -13,11 +13,15 @@ namespace Tensorflow.Keras.Layers | |||||
| { | { | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | ||||
| ======= | ======= | ||||
| protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| if (data_format == "channels_last") | if (data_format == "channels_last") | ||||
| return math_ops.reduce_max(inputs, (1, 2), false); | return math_ops.reduce_max(inputs, (1, 2), false); | ||||
| @@ -37,11 +37,15 @@ namespace Tensorflow.Keras.Layers | |||||
| input_spec = new InputSpec(ndim: 3); | input_spec = new InputSpec(ndim: 3); | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | ||||
| ======= | ======= | ||||
| protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| int pad_axis = args.DataFormat == "channels_first" ? 2 : 3; | int pad_axis = args.DataFormat == "channels_first" ? 2 : 3; | ||||
| inputs = tf.expand_dims(inputs, pad_axis); | inputs = tf.expand_dims(inputs, pad_axis); | ||||
| @@ -37,11 +37,15 @@ namespace Tensorflow.Keras.Layers | |||||
| input_spec = new InputSpec(ndim: 4); | input_spec = new InputSpec(ndim: 4); | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | ||||
| ======= | ======= | ||||
| protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| int[] pool_shape; | int[] pool_shape; | ||||
| int[] strides; | int[] strides; | ||||
| @@ -15,11 +15,15 @@ namespace Tensorflow.Keras.Layers | |||||
| this.args = args; | this.args = args; | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | ||||
| ======= | ======= | ||||
| protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| var depth = args.NumTokens; | var depth = args.NumTokens; | ||||
| var max_value = tf.reduce_max(inputs); | var max_value = tf.reduce_max(inputs); | ||||
| @@ -18,11 +18,15 @@ namespace Tensorflow.Keras.Layers | |||||
| this.args = args; | this.args = args; | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | ||||
| ======= | ======= | ||||
| protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| scale = constant_op.constant(args.Scale, args.DType); | scale = constant_op.constant(args.Scale, args.DType); | ||||
| offset = constant_op.constant(args.Offset, args.DType); | offset = constant_op.constant(args.Offset, args.DType); | ||||
| @@ -20,11 +20,15 @@ namespace Tensorflow.Keras.Layers | |||||
| this.args = args; | this.args = args; | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | ||||
| ======= | ======= | ||||
| protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| return image_ops_impl.resize_images_v2(inputs, new[] { args.Height, args.Width }, method: args.Interpolation); | return image_ops_impl.resize_images_v2(inputs, new[] { args.Height, args.Width }, method: args.Interpolation); | ||||
| } | } | ||||
| @@ -16,11 +16,15 @@ namespace Tensorflow.Keras.Layers | |||||
| this.args = args; | this.args = args; | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | ||||
| ======= | ======= | ||||
| protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| if (training == null) | if (training == null) | ||||
| training = false; | training = false; | ||||
| @@ -29,11 +29,15 @@ namespace Tensorflow.Keras.Layers.Reshaping | |||||
| _buildInputShape = input_shape; | _buildInputShape = input_shape; | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | ||||
| ======= | ======= | ||||
| protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| Tensor output = inputs; | Tensor output = inputs; | ||||
| if (output.rank != 3) | if (output.rank != 3) | ||||
| @@ -22,11 +22,15 @@ namespace Tensorflow.Keras.Layers.Reshaping | |||||
| built = true; | built = true; | ||||
| _buildInputShape = input_shape; | _buildInputShape = input_shape; | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | ||||
| ======= | ======= | ||||
| protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| Tensor output = inputs; | Tensor output = inputs; | ||||
| if (output.rank != 4) | if (output.rank != 4) | ||||
| @@ -22,11 +22,15 @@ namespace Tensorflow.Keras.Layers.Reshaping | |||||
| _buildInputShape = input_shape; | _buildInputShape = input_shape; | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | ||||
| ======= | ======= | ||||
| protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| Tensor output = inputs; | Tensor output = inputs; | ||||
| if (output.rank != 5) | if (output.rank != 5) | ||||
| @@ -24,11 +24,15 @@ namespace Tensorflow.Keras.Layers | |||||
| _channels_first = args.DataFormat == "channels_first"; | _channels_first = args.DataFormat == "channels_first"; | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | ||||
| ======= | ======= | ||||
| protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| if (_channels_first) | if (_channels_first) | ||||
| { | { | ||||
| @@ -29,11 +29,15 @@ namespace Tensorflow.Keras.Layers { | |||||
| built = true; | built = true; | ||||
| _buildInputShape = input_shape; | _buildInputShape = input_shape; | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | ||||
| ======= | ======= | ||||
| protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| Tensor outputs = inputs; | Tensor outputs = inputs; | ||||
| return tf.transpose(outputs, new Axis(permute)); | return tf.transpose(outputs, new Axis(permute)); | ||||
| @@ -20,11 +20,15 @@ namespace Tensorflow.Keras.Layers | |||||
| this.args = args; | this.args = args; | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | ||||
| ======= | ======= | ||||
| protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| var shapes = new List<Tensor>(); | var shapes = new List<Tensor>(); | ||||
| shapes.Add(array_ops.shape(inputs)[0]); | shapes.Add(array_ops.shape(inputs)[0]); | ||||
| @@ -25,11 +25,15 @@ namespace Tensorflow.Keras.Layers | |||||
| inputSpec = new InputSpec(ndim: 4); | inputSpec = new InputSpec(ndim: 4); | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | ||||
| ======= | ======= | ||||
| protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| return keras.backend.resize_images(inputs, | return keras.backend.resize_images(inputs, | ||||
| size[0], size[1], | size[0], size[1], | ||||
| @@ -27,11 +27,15 @@ namespace Tensorflow.Keras.Layers | |||||
| this.input_spec = new InputSpec(ndim: 4); | this.input_spec = new InputSpec(ndim: 4); | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | ||||
| ======= | ======= | ||||
| protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| return keras.backend.spatial_2d_padding(inputs, | return keras.backend.spatial_2d_padding(inputs, | ||||
| padding: padding, | padding: padding, | ||||
| @@ -1,5 +1,6 @@ | |||||
| using System; | using System; | ||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||
| <<<<<<< HEAD | |||||
| using Tensorflow.Keras.ArgsDefinition; | using Tensorflow.Keras.ArgsDefinition; | ||||
| using Tensorflow.Keras.ArgsDefinition.Rnn; | using Tensorflow.Keras.ArgsDefinition.Rnn; | ||||
| using Tensorflow.Keras.Engine; | using Tensorflow.Keras.Engine; | ||||
| @@ -14,6 +15,41 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| public float recurrent_dropout; | public float recurrent_dropout; | ||||
| // Get the dropout mask for RNN cell's input. | // Get the dropout mask for RNN cell's input. | ||||
| public Tensors? get_dropout_maskcell_for_cell(Tensors input, bool training, int count = 1) | public Tensors? get_dropout_maskcell_for_cell(Tensors input, bool training, int count = 1) | ||||
| ======= | |||||
| using System.Text; | |||||
| using Tensorflow.Common.Types; | |||||
| using Tensorflow.Keras.ArgsDefinition; | |||||
| using Tensorflow.Keras.Engine; | |||||
| namespace Tensorflow.Keras.Layers.Rnn | |||||
| { | |||||
| public abstract class DropoutRNNCellMixin: RnnCellBase | |||||
| { | |||||
| public float dropout; | |||||
| public float recurrent_dropout; | |||||
| // TODO(Rinne): deal with cache. | |||||
| public DropoutRNNCellMixin(LayerArgs args): base(args) | |||||
| { | |||||
| } | |||||
| protected void _create_non_trackable_mask_cache() | |||||
| { | |||||
| } | |||||
| public void reset_dropout_mask() | |||||
| { | |||||
| } | |||||
| public void reset_recurrent_dropout_mask() | |||||
| { | |||||
| } | |||||
| public Tensors? get_dropout_mask_for_cell(Tensors input, bool training, int count = 1) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| if (dropout == 0f) | if (dropout == 0f) | ||||
| return null; | return null; | ||||
| @@ -25,7 +61,11 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| } | } | ||||
| // Get the recurrent dropout mask for RNN cell. | // Get the recurrent dropout mask for RNN cell. | ||||
| <<<<<<< HEAD | |||||
| public Tensors? get_recurrent_dropout_maskcell_for_cell(Tensors input, bool training, int count = 1) | public Tensors? get_recurrent_dropout_maskcell_for_cell(Tensors input, bool training, int count = 1) | ||||
| ======= | |||||
| public Tensors? get_recurrent_dropout_mask_for_cell(Tensors input, bool training, int count = 1) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| if (dropout == 0f) | if (dropout == 0f) | ||||
| return null; | return null; | ||||
| @@ -78,6 +118,9 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| return dropped_inputs(); | return dropped_inputs(); | ||||
| } | } | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| } | } | ||||
| @@ -27,6 +27,7 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| .ToArray(); | .ToArray(); | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | ||||
| { | { | ||||
| @@ -36,6 +37,11 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| { | { | ||||
| return base.Call(inputs, initial_state: initial_state, training: training); | return base.Call(inputs, initial_state: initial_state, training: training); | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | |||||
| { | |||||
| return base.Call(inputs, initial_state: state, training: training); | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -1,4 +1,7 @@ | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| <<<<<<< HEAD | |||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| using OneOf; | using OneOf; | ||||
| using System; | using System; | ||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||
| @@ -16,15 +19,21 @@ using Tensorflow.Keras.Engine; | |||||
| using Tensorflow.Keras.Saving; | using Tensorflow.Keras.Saving; | ||||
| using Tensorflow.Util; | using Tensorflow.Util; | ||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| <<<<<<< HEAD | |||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| using Tensorflow.Common.Extensions; | using Tensorflow.Common.Extensions; | ||||
| using System.Linq.Expressions; | using System.Linq.Expressions; | ||||
| using Tensorflow.Keras.Utils; | using Tensorflow.Keras.Utils; | ||||
| using Tensorflow.Common.Types; | using Tensorflow.Common.Types; | ||||
| <<<<<<< HEAD | |||||
| ======= | ======= | ||||
| using OneOf; | using OneOf; | ||||
| using OneOf.Types; | using OneOf.Types; | ||||
| using Tensorflow.Common.Extensions; | using Tensorflow.Common.Extensions; | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| // from tensorflow.python.distribute import distribution_strategy_context as ds_context; | // from tensorflow.python.distribute import distribution_strategy_context as ds_context; | ||||
| namespace Tensorflow.Keras.Layers.Rnn | namespace Tensorflow.Keras.Layers.Rnn | ||||
| @@ -37,6 +46,9 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| public class RNN : RnnBase | public class RNN : RnnBase | ||||
| { | { | ||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| <<<<<<< HEAD | |||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| private RNNArgs _args; | private RNNArgs _args; | ||||
| private object _input_spec = null; // or NoneValue?? | private object _input_spec = null; // or NoneValue?? | ||||
| private object _state_spec = null; | private object _state_spec = null; | ||||
| @@ -46,6 +58,7 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| protected IVariableV1 _kernel; | protected IVariableV1 _kernel; | ||||
| protected IVariableV1 _bias; | protected IVariableV1 _bias; | ||||
| protected IRnnCell _cell; | protected IRnnCell _cell; | ||||
| <<<<<<< HEAD | |||||
| ======= | ======= | ||||
| private RNNArgs args; | private RNNArgs args; | ||||
| private object input_spec = null; // or NoneValue?? | private object input_spec = null; // or NoneValue?? | ||||
| @@ -57,6 +70,8 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| protected IVariableV1 bias; | protected IVariableV1 bias; | ||||
| protected ILayer cell; | protected ILayer cell; | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| public RNN(RNNArgs args) : base(PreConstruct(args)) | public RNN(RNNArgs args) : base(PreConstruct(args)) | ||||
| { | { | ||||
| @@ -65,11 +80,15 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| // if is StackedRnncell | // if is StackedRnncell | ||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| <<<<<<< HEAD | |||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| if (args.Cells != null) | if (args.Cells != null) | ||||
| { | { | ||||
| _cell = new StackedRNNCells(new StackedRNNCellsArgs | _cell = new StackedRNNCells(new StackedRNNCellsArgs | ||||
| { | { | ||||
| Cells = args.Cells | Cells = args.Cells | ||||
| <<<<<<< HEAD | |||||
| ======= | ======= | ||||
| if (args.Cell.IsT0) | if (args.Cell.IsT0) | ||||
| { | { | ||||
| @@ -77,10 +96,13 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| { | { | ||||
| Cells = args.Cell.AsT0, | Cells = args.Cell.AsT0, | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| }); | }); | ||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| _cell = args.Cell; | _cell = args.Cell; | ||||
| } | } | ||||
| @@ -109,6 +131,10 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| // the input spec will be the list of specs for nested inputs, the structure | // the input spec will be the list of specs for nested inputs, the structure | ||||
| // of the input_spec will be the same as the input. | // of the input_spec will be the same as the input. | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| _cell = args.Cell; | |||||
| } | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| // get input_shape | // get input_shape | ||||
| _args = PreConstruct(args); | _args = PreConstruct(args); | ||||
| @@ -227,6 +253,7 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| { | { | ||||
| return output_mask; | return output_mask; | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| } | } | ||||
| // States is a tuple consist of cell states_size, like (cell1.state_size, cell2.state_size,...) | // States is a tuple consist of cell states_size, like (cell1.state_size, cell2.state_size,...) | ||||
| @@ -337,12 +364,15 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| { | { | ||||
| return output_mask; | return output_mask; | ||||
| } | } | ||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| } | } | ||||
| public override void build(KerasShapesWrapper input_shape) | public override void build(KerasShapesWrapper input_shape) | ||||
| { | { | ||||
| object get_input_spec(Shape shape) | object get_input_spec(Shape shape) | ||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| <<<<<<< HEAD | |||||
| ======= | ======= | ||||
| { | { | ||||
| var input_spec_shape = shape.as_int_list(); | var input_spec_shape = shape.as_int_list(); | ||||
| @@ -391,6 +421,11 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| { | { | ||||
| var input_spec_shape = shape.as_int_list(); | var input_spec_shape = shape.as_int_list(); | ||||
| ======= | |||||
| { | |||||
| var input_spec_shape = shape.as_int_list(); | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| var (batch_index, time_step_index) = _args.TimeMajor ? (1, 0) : (0, 1); | var (batch_index, time_step_index) = _args.TimeMajor ? (1, 0) : (0, 1); | ||||
| if (!_args.Stateful) | if (!_args.Stateful) | ||||
| { | { | ||||
| @@ -437,6 +472,9 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| } | } | ||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| <<<<<<< HEAD | |||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| /// <summary> | /// <summary> | ||||
| /// | /// | ||||
| /// </summary> | /// </summary> | ||||
| @@ -460,6 +498,7 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| //var (inputs_padded, row_length) = BackendImpl.convert_inputs_if_ragged(inputs); | //var (inputs_padded, row_length) = BackendImpl.convert_inputs_if_ragged(inputs); | ||||
| // 暂时先不接受ragged tensor | // 暂时先不接受ragged tensor | ||||
| int row_length = 0; // TODO(Rinne): support this param. | int row_length = 0; // TODO(Rinne): support this param. | ||||
| <<<<<<< HEAD | |||||
| ======= | ======= | ||||
| // inputs: Tensors | // inputs: Tensors | ||||
| // mask: Binary tensor of shape [batch_size, timesteps] indicating whether a given timestep should be masked | // mask: Binary tensor of shape [batch_size, timesteps] indicating whether a given timestep should be masked | ||||
| @@ -472,17 +511,23 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| // 暂时先不接受ragged tensor | // 暂时先不接受ragged tensor | ||||
| int? row_length = null; | int? row_length = null; | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| bool is_ragged_input = false; | bool is_ragged_input = false; | ||||
| _validate_args_if_ragged(is_ragged_input, mask); | _validate_args_if_ragged(is_ragged_input, mask); | ||||
| (inputs, initial_state, constants) = _process_inputs(inputs, initial_state, constants); | (inputs, initial_state, constants) = _process_inputs(inputs, initial_state, constants); | ||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| <<<<<<< HEAD | |||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| _maybe_reset_cell_dropout_mask(_cell); | _maybe_reset_cell_dropout_mask(_cell); | ||||
| if (_cell is StackedRNNCells) | if (_cell is StackedRNNCells) | ||||
| { | { | ||||
| var stack_cell = _cell as StackedRNNCells; | var stack_cell = _cell as StackedRNNCells; | ||||
| foreach (IRnnCell cell in stack_cell.Cells) | foreach (IRnnCell cell in stack_cell.Cells) | ||||
| <<<<<<< HEAD | |||||
| ======= | ======= | ||||
| _maybe_reset_cell_dropout_mask(cell); | _maybe_reset_cell_dropout_mask(cell); | ||||
| if (cell is StackedRNNCells) | if (cell is StackedRNNCells) | ||||
| @@ -490,6 +535,8 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| var stack_cell = cell as StackedRNNCells; | var stack_cell = cell as StackedRNNCells; | ||||
| foreach (var cell in stack_cell.Cells) | foreach (var cell in stack_cell.Cells) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| _maybe_reset_cell_dropout_mask(cell); | _maybe_reset_cell_dropout_mask(cell); | ||||
| } | } | ||||
| @@ -499,11 +546,15 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| { | { | ||||
| // Time step masks must be the same for each input. | // Time step masks must be the same for each input. | ||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| <<<<<<< HEAD | |||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| mask = mask.Flatten().First(); | mask = mask.Flatten().First(); | ||||
| } | } | ||||
| Shape input_shape; | Shape input_shape; | ||||
| if (!inputs.IsNested()) | if (!inputs.IsNested()) | ||||
| <<<<<<< HEAD | |||||
| ======= | ======= | ||||
| mask = nest.flatten(mask)[0]; | mask = nest.flatten(mask)[0]; | ||||
| } | } | ||||
| @@ -511,21 +562,28 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| Shape input_shape; | Shape input_shape; | ||||
| if (nest.is_nested(inputs)) | if (nest.is_nested(inputs)) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| // In the case of nested input, use the first element for shape check | // In the case of nested input, use the first element for shape check | ||||
| // input_shape = nest.flatten(inputs)[0].shape; | // input_shape = nest.flatten(inputs)[0].shape; | ||||
| // TODO(Wanglongzhi2001) | // TODO(Wanglongzhi2001) | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| input_shape = inputs.Flatten().First().shape; | input_shape = inputs.Flatten().First().shape; | ||||
| ======= | ======= | ||||
| input_shape = nest.flatten(inputs)[0].shape; | input_shape = nest.flatten(inputs)[0].shape; | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| input_shape = inputs.Flatten().First().shape; | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| input_shape = inputs.shape; | input_shape = inputs.shape; | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| var timesteps = _args.TimeMajor ? input_shape[0] : input_shape[1]; | var timesteps = _args.TimeMajor ? input_shape[0] : input_shape[1]; | ||||
| @@ -535,6 +593,11 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| if (args.Unroll && timesteps != null) | if (args.Unroll && timesteps != null) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| var timesteps = _args.TimeMajor ? input_shape[0] : input_shape[1]; | |||||
| if (_args.Unroll && timesteps == null) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| throw new ValueError( | throw new ValueError( | ||||
| "Cannot unroll a RNN if the " + | "Cannot unroll a RNN if the " + | ||||
| @@ -553,6 +616,9 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| // cell_call_fn = (self.cell.__call__ if callable(self.cell) else self.cell.call) | // cell_call_fn = (self.cell.__call__ if callable(self.cell) else self.cell.call) | ||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| <<<<<<< HEAD | |||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| Func<Tensors, Tensors, (Tensors, Tensors)> step; | Func<Tensors, Tensors, (Tensors, Tensors)> step; | ||||
| bool is_tf_rnn_cell = _cell.IsTFRnnCell; | bool is_tf_rnn_cell = _cell.IsTFRnnCell; | ||||
| if (constants is not null) | if (constants is not null) | ||||
| @@ -561,6 +627,7 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| { | { | ||||
| throw new ValueError( | throw new ValueError( | ||||
| $"RNN cell {_cell} does not support constants." + | $"RNN cell {_cell} does not support constants." + | ||||
| <<<<<<< HEAD | |||||
| ======= | ======= | ||||
| var cell_call_fn = cell.Call; | var cell_call_fn = cell.Call; | ||||
| Func<Tensors, Tensors, (Tensors, Tensors)> step; | Func<Tensors, Tensors, (Tensors, Tensors)> step; | ||||
| @@ -573,17 +640,23 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| throw new ValueError( | throw new ValueError( | ||||
| $"RNN cell {cell} does not support constants." + | $"RNN cell {cell} does not support constants." + | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| $"Received: constants={constants}"); | $"Received: constants={constants}"); | ||||
| } | } | ||||
| step = (inputs, states) => | step = (inputs, states) => | ||||
| { | { | ||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| <<<<<<< HEAD | |||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| constants = new Tensors(states.TakeLast(_num_constants)); | constants = new Tensors(states.TakeLast(_num_constants)); | ||||
| states = new Tensors(states.SkipLast(_num_constants)); | states = new Tensors(states.SkipLast(_num_constants)); | ||||
| states = len(states) == 1 && is_tf_rnn_cell ? new Tensors(states[0]) : states; | states = len(states) == 1 && is_tf_rnn_cell ? new Tensors(states[0]) : states; | ||||
| var (output, new_states) = _cell.Apply(inputs, states, optional_args: new RnnOptionalArgs() { Constants = constants }); | var (output, new_states) = _cell.Apply(inputs, states, optional_args: new RnnOptionalArgs() { Constants = constants }); | ||||
| return (output, new_states.Single); | return (output, new_states.Single); | ||||
| <<<<<<< HEAD | |||||
| ======= | ======= | ||||
| // constants = states[-self._num_constants :] | // constants = states[-self._num_constants :] | ||||
| constants = states.numpy()[new Slice(states.Length - _num_constants, states.Length)]; | constants = states.numpy()[new Slice(states.Length - _num_constants, states.Length)]; | ||||
| @@ -599,6 +672,8 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| } | } | ||||
| return (output, new_states); | return (output, new_states); | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| }; | }; | ||||
| } | } | ||||
| else | else | ||||
| @@ -606,6 +681,9 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| step = (inputs, states) => | step = (inputs, states) => | ||||
| { | { | ||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| <<<<<<< HEAD | |||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| states = len(states) == 1 && is_tf_rnn_cell ? new Tensors(states.First()) : states; | states = len(states) == 1 && is_tf_rnn_cell ? new Tensors(states.First()) : states; | ||||
| var (output, new_states) = _cell.Apply(inputs, states); | var (output, new_states) = _cell.Apply(inputs, states); | ||||
| return (output, new_states); | return (output, new_states); | ||||
| @@ -635,6 +713,7 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| { | { | ||||
| // TODO(Rinne): add go_backwards parameter and revise the `row_length` param | // TODO(Rinne): add go_backwards parameter and revise the `row_length` param | ||||
| output = keras.backend.maybe_convert_to_ragged(is_ragged_input, outputs, row_length, false); | output = keras.backend.maybe_convert_to_ragged(is_ragged_input, outputs, row_length, false); | ||||
| <<<<<<< HEAD | |||||
| ======= | ======= | ||||
| // states = (states[0] if len(states) == 1 and is_tf_rnn_cell else states) | // states = (states[0] if len(states) == 1 and is_tf_rnn_cell else states) | ||||
| states = states.Length == 1 ? states[0] : states; | states = states.Length == 1 ? states[0] : states; | ||||
| @@ -670,12 +749,15 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| throw new NotImplementedException("this argument havn't been developed!"); | throw new NotImplementedException("this argument havn't been developed!"); | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| output = last_output; | output = last_output; | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| if (_args.ReturnState) | if (_args.ReturnState) | ||||
| { | { | ||||
| @@ -684,6 +766,10 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| { | { | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| if (_args.ReturnState) | |||||
| { | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| foreach (var state in states) | foreach (var state in states) | ||||
| { | { | ||||
| output.Add(state); | output.Add(state); | ||||
| @@ -697,6 +783,9 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| } | } | ||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| <<<<<<< HEAD | |||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| public override Tensors Apply(Tensors inputs, Tensors initial_states = null, bool training = false, IOptionalArgs? optional_args = null) | public override Tensors Apply(Tensors inputs, Tensors initial_states = null, bool training = false, IOptionalArgs? optional_args = null) | ||||
| { | { | ||||
| RnnOptionalArgs? rnn_optional_args = optional_args as RnnOptionalArgs; | RnnOptionalArgs? rnn_optional_args = optional_args as RnnOptionalArgs; | ||||
| @@ -728,6 +817,7 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| { | { | ||||
| initial_state = new Tensors(inputs.Skip(1).SkipLast(_num_constants)); | initial_state = new Tensors(inputs.Skip(1).SkipLast(_num_constants)); | ||||
| constants = new Tensors(inputs.TakeLast(_num_constants)); | constants = new Tensors(inputs.TakeLast(_num_constants)); | ||||
| <<<<<<< HEAD | |||||
| ======= | ======= | ||||
| private (Tensors inputs, Tensors initial_state, Tensors constants) _process_inputs(Tensor inputs, Tensors initial_state, Tensors constants) | private (Tensors inputs, Tensors initial_state, Tensors constants) _process_inputs(Tensor inputs, Tensors initial_state, Tensors constants) | ||||
| { | { | ||||
| @@ -742,12 +832,15 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| initial_state = inputs[new Slice(1, len(inputs) - _num_constants)]; | initial_state = inputs[new Slice(1, len(inputs) - _num_constants)]; | ||||
| constants = inputs[new Slice(len(inputs) - _num_constants, len(inputs))]; | constants = inputs[new Slice(len(inputs) - _num_constants, len(inputs))]; | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| } | } | ||||
| if (len(initial_state) == 0) | if (len(initial_state) == 0) | ||||
| initial_state = null; | initial_state = null; | ||||
| inputs = inputs[0]; | inputs = inputs[0]; | ||||
| } | } | ||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| <<<<<<< HEAD | |||||
| if (_args.Stateful) | if (_args.Stateful) | ||||
| @@ -755,6 +848,11 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| if (args.Stateful) | if (args.Stateful) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| if (_args.Stateful) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| if (initial_state != null) | if (initial_state != null) | ||||
| { | { | ||||
| @@ -762,11 +860,15 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| foreach (var s in nest.flatten(States)) | foreach (var s in nest.flatten(States)) | ||||
| { | { | ||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| <<<<<<< HEAD | |||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| tmp.add(tf.math.count_nonzero(s.Single())); | tmp.add(tf.math.count_nonzero(s.Single())); | ||||
| } | } | ||||
| var non_zero_count = tf.add_n(tmp); | var non_zero_count = tf.add_n(tmp); | ||||
| //initial_state = tf.cond(non_zero_count > 0, () => States, () => initial_state); | //initial_state = tf.cond(non_zero_count > 0, () => States, () => initial_state); | ||||
| if ((int)non_zero_count.numpy() > 0) | if ((int)non_zero_count.numpy() > 0) | ||||
| <<<<<<< HEAD | |||||
| ======= | ======= | ||||
| tmp.add(tf.math.count_nonzero((Tensor)s)); | tmp.add(tf.math.count_nonzero((Tensor)s)); | ||||
| } | } | ||||
| @@ -774,6 +876,8 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| //initial_state = tf.cond(non_zero_count > 0, () => States, () => initial_state); | //initial_state = tf.cond(non_zero_count > 0, () => States, () => initial_state); | ||||
| if((int)non_zero_count.numpy() > 0) | if((int)non_zero_count.numpy() > 0) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| initial_state = States; | initial_state = States; | ||||
| } | } | ||||
| @@ -783,6 +887,9 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| initial_state = States; | initial_state = States; | ||||
| } | } | ||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| <<<<<<< HEAD | |||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| // TODO(Wanglongzhi2001), | // TODO(Wanglongzhi2001), | ||||
| // initial_state = tf.nest.map_structure( | // initial_state = tf.nest.map_structure( | ||||
| //# When the layer has a inferred dtype, use the dtype from the | //# When the layer has a inferred dtype, use the dtype from the | ||||
| @@ -795,17 +902,21 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| } | } | ||||
| else if (initial_state is null) | else if (initial_state is null) | ||||
| <<<<<<< HEAD | |||||
| ======= | ======= | ||||
| } | } | ||||
| else if(initial_state != null) | else if(initial_state != null) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| initial_state = get_initial_state(inputs); | initial_state = get_initial_state(inputs); | ||||
| } | } | ||||
| if (initial_state.Length != States.Length) | if (initial_state.Length != States.Length) | ||||
| { | { | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| throw new ValueError($"Layer {this} expects {States.Length} state(s), " + | throw new ValueError($"Layer {this} expects {States.Length} state(s), " + | ||||
| $"but it received {initial_state.Length} " + | $"but it received {initial_state.Length} " + | ||||
| @@ -816,6 +927,11 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| $"but it received {initial_state.Length} " + | $"but it received {initial_state.Length} " + | ||||
| $"initial state(s). Input received: {inputs}"); | $"initial state(s). Input received: {inputs}"); | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| throw new ValueError($"Layer {this} expects {States.Length} state(s), " + | |||||
| $"but it received {initial_state.Length} " + | |||||
| $"initial state(s). Input received: {inputs}"); | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| } | } | ||||
| return (inputs, initial_state, constants); | return (inputs, initial_state, constants); | ||||
| @@ -823,20 +939,28 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| private void _validate_args_if_ragged(bool is_ragged_input, Tensors mask) | private void _validate_args_if_ragged(bool is_ragged_input, Tensors mask) | ||||
| { | { | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| if (!is_ragged_input) | if (!is_ragged_input) | ||||
| ======= | ======= | ||||
| if (!is_ragged_input) | if (!is_ragged_input) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| if (!is_ragged_input) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| return; | return; | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| if (_args.Unroll) | if (_args.Unroll) | ||||
| ======= | ======= | ||||
| if (args.Unroll) | if (args.Unroll) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| if (_args.Unroll) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| throw new ValueError("The input received contains RaggedTensors and does " + | throw new ValueError("The input received contains RaggedTensors and does " + | ||||
| "not support unrolling. Disable unrolling by passing " + | "not support unrolling. Disable unrolling by passing " + | ||||
| @@ -855,11 +979,15 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| void _maybe_reset_cell_dropout_mask(ILayer cell) | void _maybe_reset_cell_dropout_mask(ILayer cell) | ||||
| { | { | ||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| <<<<<<< HEAD | |||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| if (cell is DropoutRNNCellMixin CellDRCMixin) | if (cell is DropoutRNNCellMixin CellDRCMixin) | ||||
| { | { | ||||
| CellDRCMixin.reset_dropout_mask(); | CellDRCMixin.reset_dropout_mask(); | ||||
| CellDRCMixin.reset_recurrent_dropout_mask(); | CellDRCMixin.reset_recurrent_dropout_mask(); | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| ======= | ======= | ||||
| //if (cell is DropoutRNNCellMixin) | //if (cell is DropoutRNNCellMixin) | ||||
| //{ | //{ | ||||
| @@ -867,6 +995,8 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| // cell.reset_recurrent_dropout_mask(); | // cell.reset_recurrent_dropout_mask(); | ||||
| //} | //} | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| } | } | ||||
| private static RNNArgs PreConstruct(RNNArgs args) | private static RNNArgs PreConstruct(RNNArgs args) | ||||
| @@ -900,7 +1030,10 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| { | { | ||||
| throw new NotImplementedException(); | throw new NotImplementedException(); | ||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| <<<<<<< HEAD | |||||
| ======= | |||||
| ======= | ======= | ||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| } | } | ||||
| // 好像不能cell不能传接口类型 | // 好像不能cell不能传接口类型 | ||||
| @@ -941,6 +1074,7 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| // }); | // }); | ||||
| <<<<<<< HEAD | |||||
| protected Tensors get_initial_state(Tensor inputs) | protected Tensors get_initial_state(Tensor inputs) | ||||
| { | { | ||||
| Type type = cell.GetType(); | Type type = cell.GetType(); | ||||
| @@ -1016,6 +1150,10 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| protected Tensors get_initial_state(Tensors inputs) | protected Tensors get_initial_state(Tensors inputs) | ||||
| { | { | ||||
| ======= | |||||
| protected Tensors get_initial_state(Tensors inputs) | |||||
| { | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| var get_initial_state_fn = _cell.GetType().GetMethod("get_initial_state"); | var get_initial_state_fn = _cell.GetType().GetMethod("get_initial_state"); | ||||
| var input = inputs[0]; | var input = inputs[0]; | ||||
| @@ -1043,11 +1181,15 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| } | } | ||||
| // Check whether the state_size contains multiple states. | // Check whether the state_size contains multiple states. | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| public static bool is_multiple_state(GeneralizedTensorShape state_size) | public static bool is_multiple_state(GeneralizedTensorShape state_size) | ||||
| ======= | ======= | ||||
| public static bool is_multiple_state(object state_size) | public static bool is_multiple_state(object state_size) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| public static bool is_multiple_state(GeneralizedTensorShape state_size) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| return state_size.Shapes.Length > 1; | return state_size.Shapes.Length > 1; | ||||
| } | } | ||||
| @@ -5,12 +5,18 @@ using Tensorflow.Keras.ArgsDefinition.Rnn; | |||||
| using Tensorflow.Keras.Engine; | using Tensorflow.Keras.Engine; | ||||
| using Tensorflow.Keras.Saving; | using Tensorflow.Keras.Saving; | ||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| <<<<<<< HEAD | |||||
| using Tensorflow.Common.Types; | using Tensorflow.Common.Types; | ||||
| using Tensorflow.Common.Extensions; | using Tensorflow.Common.Extensions; | ||||
| using Tensorflow.Keras.Utils; | using Tensorflow.Keras.Utils; | ||||
| ======= | ======= | ||||
| using Tensorflow.Util; | using Tensorflow.Util; | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| using Tensorflow.Common.Types; | |||||
| using Tensorflow.Common.Extensions; | |||||
| using Tensorflow.Keras.Utils; | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| namespace Tensorflow.Keras.Layers.Rnn | namespace Tensorflow.Keras.Layers.Rnn | ||||
| { | { | ||||
| @@ -24,6 +30,9 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| public class SimpleRNNCell : DropoutRNNCellMixin | public class SimpleRNNCell : DropoutRNNCellMixin | ||||
| { | { | ||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| <<<<<<< HEAD | |||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| SimpleRNNCellArgs _args; | SimpleRNNCellArgs _args; | ||||
| IVariableV1 _kernel; | IVariableV1 _kernel; | ||||
| IVariableV1 _recurrent_kernel; | IVariableV1 _recurrent_kernel; | ||||
| @@ -37,6 +46,7 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| public override bool SupportOptionalArgs => false; | public override bool SupportOptionalArgs => false; | ||||
| public SimpleRNNCell(SimpleRNNCellArgs args) : base(args) | public SimpleRNNCell(SimpleRNNCellArgs args) : base(args) | ||||
| <<<<<<< HEAD | |||||
| { | { | ||||
| this._args = args; | this._args = args; | ||||
| ======= | ======= | ||||
| @@ -49,16 +59,24 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| { | { | ||||
| this.args = args; | this.args = args; | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| { | |||||
| this._args = args; | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| if (args.Units <= 0) | if (args.Units <= 0) | ||||
| { | { | ||||
| throw new ValueError( | throw new ValueError( | ||||
| $"units must be a positive integer, got {args.Units}"); | $"units must be a positive integer, got {args.Units}"); | ||||
| } | } | ||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| <<<<<<< HEAD | |||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| this._args.Dropout = Math.Min(1f, Math.Max(0f, this._args.Dropout)); | this._args.Dropout = Math.Min(1f, Math.Max(0f, this._args.Dropout)); | ||||
| this._args.RecurrentDropout = Math.Min(1f, Math.Max(0f, this._args.RecurrentDropout)); | this._args.RecurrentDropout = Math.Min(1f, Math.Max(0f, this._args.RecurrentDropout)); | ||||
| _state_size = new GeneralizedTensorShape(args.Units); | _state_size = new GeneralizedTensorShape(args.Units); | ||||
| _output_size = new GeneralizedTensorShape(args.Units); | _output_size = new GeneralizedTensorShape(args.Units); | ||||
| <<<<<<< HEAD | |||||
| ======= | ======= | ||||
| this.args.Dropout = Math.Min(1f, Math.Max(0f, this.args.Dropout)); | this.args.Dropout = Math.Min(1f, Math.Max(0f, this.args.Dropout)); | ||||
| this.args.RecurrentDropout = Math.Min(1f, Math.Max(0f, this.args.RecurrentDropout)); | this.args.RecurrentDropout = Math.Min(1f, Math.Max(0f, this.args.RecurrentDropout)); | ||||
| @@ -69,6 +87,8 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| DRCMixin.dropout = this.args.Dropout; | DRCMixin.dropout = this.args.Dropout; | ||||
| DRCMixin.recurrent_dropout = this.args.RecurrentDropout; | DRCMixin.recurrent_dropout = this.args.RecurrentDropout; | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| } | } | ||||
| public override void build(KerasShapesWrapper input_shape) | public override void build(KerasShapesWrapper input_shape) | ||||
| @@ -96,6 +116,9 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| } | } | ||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| <<<<<<< HEAD | |||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| // TODO(Rinne): revise the trining param (with refactoring of the framework) | // TODO(Rinne): revise the trining param (with refactoring of the framework) | ||||
| protected override Tensors Call(Tensors inputs, Tensors states = null, bool? training = null, IOptionalArgs? optional_args = null) | protected override Tensors Call(Tensors inputs, Tensors states = null, bool? training = null, IOptionalArgs? optional_args = null) | ||||
| { | { | ||||
| @@ -103,6 +126,7 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| Tensors prev_output = Nest.IsNested(states) ? new Tensors(states[0]) : states; | Tensors prev_output = Nest.IsNested(states) ? new Tensors(states[0]) : states; | ||||
| var dp_mask = get_dropout_mask_for_cell(inputs, training.Value); | var dp_mask = get_dropout_mask_for_cell(inputs, training.Value); | ||||
| var rec_dp_mask = get_recurrent_dropout_mask_for_cell(prev_output, training.Value); | var rec_dp_mask = get_recurrent_dropout_mask_for_cell(prev_output, training.Value); | ||||
| <<<<<<< HEAD | |||||
| ======= | ======= | ||||
| protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| { | { | ||||
| @@ -111,12 +135,17 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| var dp_mask = DRCMixin.get_dropout_maskcell_for_cell(inputs, training.Value); | var dp_mask = DRCMixin.get_dropout_maskcell_for_cell(inputs, training.Value); | ||||
| var rec_dp_mask = DRCMixin.get_recurrent_dropout_maskcell_for_cell(prev_output, training.Value); | var rec_dp_mask = DRCMixin.get_recurrent_dropout_maskcell_for_cell(prev_output, training.Value); | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| Tensor h; | Tensor h; | ||||
| var ranks = inputs.rank; | var ranks = inputs.rank; | ||||
| if (dp_mask != null) | if (dp_mask != null) | ||||
| { | { | ||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| <<<<<<< HEAD | |||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| h = math_ops.matmul(math_ops.multiply(inputs.Single, dp_mask.Single), _kernel.AsTensor()); | h = math_ops.matmul(math_ops.multiply(inputs.Single, dp_mask.Single), _kernel.AsTensor()); | ||||
| } | } | ||||
| @@ -128,6 +157,7 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| if (_bias != null) | if (_bias != null) | ||||
| { | { | ||||
| h = tf.nn.bias_add(h, _bias); | h = tf.nn.bias_add(h, _bias); | ||||
| <<<<<<< HEAD | |||||
| ======= | ======= | ||||
| if (ranks > 2) | if (ranks > 2) | ||||
| { | { | ||||
| @@ -155,11 +185,16 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| { | { | ||||
| h = tf.nn.bias_add(h, bias); | h = tf.nn.bias_add(h, bias); | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| } | } | ||||
| if (rec_dp_mask != null) | if (rec_dp_mask != null) | ||||
| { | { | ||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| <<<<<<< HEAD | |||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| prev_output = math_ops.multiply(prev_output, rec_dp_mask); | prev_output = math_ops.multiply(prev_output, rec_dp_mask); | ||||
| } | } | ||||
| @@ -184,6 +219,7 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| public Tensors get_initial_state(Tensors inputs = null, long? batch_size = null, TF_DataType? dtype = null) | public Tensors get_initial_state(Tensors inputs = null, long? batch_size = null, TF_DataType? dtype = null) | ||||
| { | { | ||||
| return RnnUtils.generate_zero_filled_state_for_cell(this, inputs, batch_size.Value, dtype.Value); | return RnnUtils.generate_zero_filled_state_for_cell(this, inputs, batch_size.Value, dtype.Value); | ||||
| <<<<<<< HEAD | |||||
| ======= | ======= | ||||
| prev_output = math_ops.multiply(prev_output, rec_dp_mask)[0]; | prev_output = math_ops.multiply(prev_output, rec_dp_mask)[0]; | ||||
| } | } | ||||
| @@ -216,6 +252,8 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| { | { | ||||
| return RNNUtils.generate_zero_filled_state_for_cell(this, inputs, batch_size, dtype); | return RNNUtils.generate_zero_filled_state_for_cell(this, inputs, batch_size, dtype); | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -9,6 +9,9 @@ using static Tensorflow.Keras.ArgsDefinition.Rnn.RNNArgs; | |||||
| using Tensorflow.Keras.Engine; | using Tensorflow.Keras.Engine; | ||||
| using Tensorflow.Keras.Saving; | using Tensorflow.Keras.Saving; | ||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| <<<<<<< HEAD | |||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| using Tensorflow.Keras.Utils; | using Tensorflow.Keras.Utils; | ||||
| namespace Tensorflow.Keras.Layers.Rnn | namespace Tensorflow.Keras.Layers.Rnn | ||||
| @@ -16,6 +19,7 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| public class StackedRNNCells : Layer, IRnnCell | public class StackedRNNCells : Layer, IRnnCell | ||||
| { | { | ||||
| public IList<IRnnCell> Cells { get; set; } | public IList<IRnnCell> Cells { get; set; } | ||||
| <<<<<<< HEAD | |||||
| ======= | ======= | ||||
| using Tensorflow.Keras.ArgsDefinition.Rnn; | using Tensorflow.Keras.ArgsDefinition.Rnn; | ||||
| @@ -25,6 +29,8 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| { | { | ||||
| public IList<IRnnArgCell> Cells { get; set; } | public IList<IRnnArgCell> Cells { get; set; } | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| public bool reverse_state_order; | public bool reverse_state_order; | ||||
| public StackedRNNCells(StackedRNNCellsArgs args) : base(args) | public StackedRNNCells(StackedRNNCellsArgs args) : base(args) | ||||
| @@ -96,11 +102,15 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| { | { | ||||
| return lastCell.OutputSize; | return lastCell.OutputSize; | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| else if (RNN.is_multiple_state(lastCell.StateSize)) | else if (RNN.is_multiple_state(lastCell.StateSize)) | ||||
| ======= | ======= | ||||
| else if (RNN.is_multiple_state(lastCell.state_size)) | else if (RNN.is_multiple_state(lastCell.state_size)) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| else if (RNN.is_multiple_state(lastCell.StateSize)) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| return lastCell.StateSize.First(); | return lastCell.StateSize.First(); | ||||
| //throw new NotImplementedException(""); | //throw new NotImplementedException(""); | ||||
| @@ -112,12 +122,16 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| } | } | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| public Tensors get_initial_state(Tensors inputs = null, long? batch_size = null, TF_DataType? dtype = null) | public Tensors get_initial_state(Tensors inputs = null, long? batch_size = null, TF_DataType? dtype = null) | ||||
| ======= | ======= | ||||
| public object get_initial_state() | public object get_initial_state() | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| public Tensors get_initial_state(Tensors inputs = null, long? batch_size = null, TF_DataType? dtype = null) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| var cells = reverse_state_order ? Cells.Reverse() : Cells; | var cells = reverse_state_order ? Cells.Reverse() : Cells; | ||||
| Tensors initial_states = new Tensors(); | Tensors initial_states = new Tensors(); | ||||
| @@ -137,11 +151,15 @@ namespace Tensorflow.Keras.Layers.Rnn | |||||
| return initial_states; | return initial_states; | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | ||||
| ======= | ======= | ||||
| public Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | public Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| // Recover per-cell states. | // Recover per-cell states. | ||||
| var state_size = reverse_state_order ? StateSize.Reverse() : StateSize; | var state_size = reverse_state_order ? StateSize.Reverse() : StateSize; | ||||
| @@ -35,11 +35,15 @@ namespace Tensorflow.Keras.Layers | |||||
| built = true; | built = true; | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | ||||
| ======= | ======= | ||||
| protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| if (tf.Context.executing_eagerly()) | if (tf.Context.executing_eagerly()) | ||||
| return DeFunCall(inputs); | return DeFunCall(inputs); | ||||
| @@ -90,11 +90,15 @@ namespace Tensorflow.Hub | |||||
| } | } | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optionalArgs = null) | protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optionalArgs = null) | ||||
| ======= | ======= | ||||
| protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | protected override Tensors Call(Tensors inputs, Tensor mask = null, bool? training = null, Tensors initial_state = null, Tensors constants = null) | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| protected override Tensors Call(Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optionalArgs = null) | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| { | { | ||||
| _check_trainability(); | _check_trainability(); | ||||
| @@ -144,6 +144,7 @@ namespace Tensorflow.Keras.UnitTest.Layers | |||||
| Assert.AreEqual(expected_output, actual_output); | Assert.AreEqual(expected_output, actual_output); | ||||
| } | } | ||||
| <<<<<<< HEAD | |||||
| <<<<<<< HEAD | <<<<<<< HEAD | ||||
| ======= | ======= | ||||
| [TestMethod] | [TestMethod] | ||||
| @@ -172,6 +173,8 @@ namespace Tensorflow.Keras.UnitTest.Layers | |||||
| } | } | ||||
| >>>>>>> master | >>>>>>> master | ||||
| ======= | |||||
| >>>>>>> 90a65d7d98b92f26574ac32392ed802a57d4d2c8 | |||||
| [TestMethod] | [TestMethod] | ||||
| public void Resizing() | public void Resizing() | ||||
| { | { | ||||