Пример #1
0
        private static RNNArgs PreConstruct(RNNArgs args)
        {
            if (args.Kwargs == null)
            {
                args.Kwargs = new Dictionary <string, object>();
            }

            // If true, the output for masked timestep will be zeros, whereas in the
            // false case, output from previous timestep is returned for masked timestep.
            var zeroOutputForMask = (bool)args.Kwargs.Get("zero_output_for_mask", false);

            TensorShape input_shape;
            var         propIS = (TensorShape)args.Kwargs.Get("input_shape", null);
            var         propID = (int?)args.Kwargs.Get("input_dim", null);
            var         propIL = (int?)args.Kwargs.Get("input_length", null);

            if (propIS == null && (propID != null || propIL != null))
            {
                input_shape = new TensorShape(
                    propIL ?? -1,
                    propID ?? -1);
                args.Kwargs["input_shape"] = input_shape;
            }

            return(args);
        }
Пример #2
0
        private static RNNArgs PreConstruct(RNNArgs args)
        {
            if (args.Kwargs == null)
            {
                args.Kwargs = new Dictionary <string, object>();
            }

            // If true, the output for masked timestep will be zeros, whereas in the
            // false case, output from previous timestep is returned for masked timestep.
            var zeroOutputForMask = (bool)args.Kwargs.Get("zero_output_for_mask", false);

            object input_shape;
            var    propIS = args.Kwargs.Get("input_shape", null);
            var    propID = args.Kwargs.Get("input_dim", null);
            var    propIL = args.Kwargs.Get("input_length", null);

            if (propIS == null && (propID != null || propIL != null))
            {
                input_shape = (
                    propIL ?? new NoneValue(),  // maybe null is needed here
                    propID ?? new NoneValue()); // and here
                args.Kwargs["input_shape"] = input_shape;
            }

            return(args);
        }
Пример #3
0
        public RNN(RNNArgs args) : base(PreConstruct(args))
        {
            this.args       = args;
            SupportsMasking = true;

            // The input shape is unknown yet, it could have nested tensor inputs, and
            // 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.

            //if(stateful)
            //{
            //    if (ds_context.has_strategy()) // ds_context????
            //    {
            //        throw new Exception("RNNs with stateful=True not yet supported with tf.distribute.Strategy");
            //    }
            //}
        }
Пример #4
0
        public RNN(RNNArgs args) : base(PreConstruct(args))
        {
            this.args       = args;
            SupportsMasking = true;

            // The input shape is unknown yet, it could have nested tensor inputs, and
            // 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.

            //self.input_spec = None
            //self.state_spec = None
            //self._states = None
            //self.constants_spec = None
            //self._num_constants = 0

            //if stateful:
            //  if ds_context.has_strategy():
            //    raise ValueError('RNNs with stateful=True not yet supported with '
            //                     'tf.distribute.Strategy.')
        }
Пример #5
0
 public RNN(RNNArgs args)
     : base(args)
 {
 }
Пример #6
0
 public SimpleRNN(RNNArgs args) : base(args)
 {
 }