You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

ZeroPadding2D.cs 1.1 kB

5 years ago
123456789101112131415161718192021222324252627282930313233343536
  1. using NumSharp;
  2. using Tensorflow.Keras.ArgsDefinition;
  3. using Tensorflow.Keras.Engine;
  4. using Tensorflow.Keras.Utils;
  5. using static Tensorflow.KerasApi;
  6. namespace Tensorflow.Keras.Layers
  7. {
  8. /// <summary>
  9. /// Zero-padding layer for 2D input (e.g. picture).
  10. ///
  11. /// This layer can add rows and columns of zeros
  12. /// at the top, bottom, left and right side of an image tensor.
  13. /// </summary>
  14. public class ZeroPadding2D : Layer
  15. {
  16. string data_format;
  17. NDArray padding;
  18. InputSpec input_spec;
  19. public ZeroPadding2D(ZeroPadding2DArgs args, string data_format = null)
  20. : base(args)
  21. {
  22. this.data_format = conv_utils.normalize_data_format(data_format);
  23. this.padding = args.Padding;
  24. this.input_spec = new InputSpec(ndim: 4);
  25. }
  26. protected override Tensors Call(Tensors inputs, Tensor state = null, bool? training = null)
  27. {
  28. return keras.backend.spatial_2d_padding(inputs,
  29. padding: padding,
  30. data_format: data_format);
  31. }
  32. }
  33. }