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.

HardSigmoid.cs 859 B

1234567891011121314151617181920212223
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using Tensorflow.Keras.ArgsDefinition;
  5. using Tensorflow.Keras.Engine;
  6. using Tensorflow.Common.Types;
  7. using static Tensorflow.Binding;
  8. namespace Tensorflow.Keras.Layers {
  9. public class HardSigmoid : Layer {
  10. public HardSigmoid ( LayerArgs args ) : base(args) {
  11. // hard sigmoid has no arguments
  12. }
  13. protected override Tensors Call ( Tensors inputs, Tensors state = null, bool? training = null, IOptionalArgs? optional_args = null ) {
  14. Tensor x = inputs;
  15. return tf.clip_by_value(
  16. tf.add(tf.multiply(x, 0.2f), 0.5f), 0f, 1f);
  17. }
  18. public override Shape ComputeOutputShape ( Shape input_shape ) {
  19. return input_shape;
  20. }
  21. }
  22. }