public RangeDataset(int stop, int start = 0, int step = 1, TF_DataType output_type = TF_DataType.TF_INT64) { var start_tensor = tf.convert_to_tensor((long)start); var step_tensor = tf.convert_to_tensor((long)step); var stop_tensor = tf.convert_to_tensor((long)stop); structure = new TensorSpec[] { new TensorSpec(new int[0], dtype: output_type) }; variant_tensor = ops.range_dataset(start_tensor, stop_tensor, step_tensor, output_types, output_shapes); }
public InputLayer(InputLayerArgs args) : base(args) { this.args = args; built = true; SupportsMasking = true; if (BatchInputShape != null) { args.BatchSize = BatchInputShape.dims[0]; args.InputShape = BatchInputShape.dims.Skip(1).ToArray(); } // moved to base class if (string.IsNullOrEmpty(args.Name)) { var prefix = "input"; name = prefix + '_' + keras.backend.get_uid(prefix); args.Name = name; } if (args.DType == TF_DataType.DtInvalid) { args.DType = args.InputTensor == null ? tf.float32 : args.InputTensor.dtype; } if (args.InputTensor == null) { if (args.InputShape != null) { args.BatchInputShape = new int[] { args.BatchSize } .Concat(args.InputShape.dims) .ToArray(); } else { args.BatchInputShape = null; } var graph = keras.backend.get_graph(); graph.as_default(); args.InputTensor = keras.backend.placeholder( shape: BatchInputShape, dtype: DType, name: Name, sparse: args.Sparse, ragged: args.Ragged); graph.Exit(); isPlaceholder = true; } // Create an input node to add to self.outbound_node // and set output_tensors' _keras_history. // input_tensor._keras_history = base_layer.KerasHistory(self, 0, 0) // input_tensor._keras_mask = None var node = new Node(new NodeArgs { Outputs = args.InputTensor }); node.Connect(this); typeSpec = new TensorSpec(args.InputTensor.TensorShape, dtype: args.InputTensor.dtype, name: Name); }