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.

Rescaling.cs 879 B

4 years ago
1234567891011121314151617181920212223242526272829303132
  1. using Tensorflow.Keras.ArgsDefinition;
  2. using Tensorflow.Keras.Engine;
  3. namespace Tensorflow.Keras.Layers
  4. {
  5. /// <summary>
  6. /// Multiply inputs by `scale` and adds `offset`.
  7. /// </summary>
  8. public class Rescaling : Layer
  9. {
  10. RescalingArgs args;
  11. Tensor scale;
  12. Tensor offset;
  13. public Rescaling(RescalingArgs args) : base(args)
  14. {
  15. this.args = args;
  16. }
  17. protected override Tensors Call(Tensors inputs, Tensor state = null, bool? training = null)
  18. {
  19. scale = constant_op.constant(args.Scale, args.DType);
  20. offset = constant_op.constant(args.Offset, args.DType);
  21. return math_ops.cast(inputs, args.DType) * scale + offset;
  22. }
  23. public override Shape ComputeOutputShape(Shape input_shape)
  24. {
  25. return input_shape;
  26. }
  27. }
  28. }