|
| 1 | +/***************************************************************************** |
| 2 | + Copyright 2018 The TensorFlow.NET Authors. All Rights Reserved. |
| 3 | +
|
| 4 | + Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + you may not use this file except in compliance with the License. |
| 6 | + You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | + Unless required by applicable law or agreed to in writing, software |
| 11 | + distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + See the License for the specific language governing permissions and |
| 14 | + limitations under the License. |
| 15 | +******************************************************************************/ |
| 16 | + |
| 17 | +using System; |
| 18 | +using System.Collections.Generic; |
| 19 | +using System.Text; |
| 20 | + |
| 21 | +namespace Tensorflow |
| 22 | +{ |
| 23 | + /// <summary> |
| 24 | + /// Abstract object representing an RNN cell. |
| 25 | + /// |
| 26 | + /// Every `RNNCell` must have the properties below and implement `call` with |
| 27 | + /// the signature `(output, next_state) = call(input, state)`. The optional |
| 28 | + /// third input argument, `scope`, is allowed for backwards compatibility |
| 29 | + /// purposes; but should be left off for new subclasses. |
| 30 | + /// |
| 31 | + /// This definition of cell differs from the definition used in the literature. |
| 32 | + /// In the literature, 'cell' refers to an object with a single scalar output. |
| 33 | + /// This definition refers to a horizontal array of such units. |
| 34 | + /// |
| 35 | + /// An RNN cell, in the most abstract setting, is anything that has |
| 36 | + /// a state and performs some operation that takes a matrix of inputs. |
| 37 | + /// This operation results in an output matrix with `self.output_size` columns. |
| 38 | + /// If `self.state_size` is an integer, this operation also results in a new |
| 39 | + /// state matrix with `self.state_size` columns. If `self.state_size` is a |
| 40 | + /// (possibly nested tuple of) TensorShape object(s), then it should return a |
| 41 | + /// matching structure of Tensors having shape `[batch_size].concatenate(s)` |
| 42 | + /// for each `s` in `self.batch_size`. |
| 43 | + /// </summary> |
| 44 | + public abstract class RNNCell : Layers.Layer |
| 45 | + { |
| 46 | + /// <summary> |
| 47 | + /// Attribute that indicates whether the cell is a TF RNN cell, due the slight |
| 48 | + /// difference between TF and Keras RNN cell. |
| 49 | + /// </summary> |
| 50 | + protected bool _is_tf_rnn_cell = false; |
| 51 | + |
| 52 | + public RNNCell(bool trainable = true, |
| 53 | + string name = null, |
| 54 | + TF_DataType dtype = TF_DataType.DtInvalid, |
| 55 | + bool? _reuse = null) : base(trainable: trainable, |
| 56 | + name: name, |
| 57 | + dtype: dtype, |
| 58 | + _reuse: _reuse) |
| 59 | + { |
| 60 | + _is_tf_rnn_cell = true; |
| 61 | + } |
| 62 | + } |
| 63 | +} |
0 commit comments