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.

Layer.FunctionalConstructionCall.cs 1.4 kB

3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System;
  2. using Tensorflow.Keras.Utils;
  3. namespace Tensorflow.Keras.Engine
  4. {
  5. public partial class Layer
  6. {
  7. Tensors FunctionalConstructionCall(Tensors inputs)
  8. {
  9. if (base_layer_utils.needs_keras_history(inputs))
  10. base_layer_utils.create_keras_history(inputs);
  11. Tensors outputs = null;
  12. using var ctxManager = CallContext.enter(build_graph: true);
  13. var graph = keras.backend.get_graph();
  14. graph.as_default();
  15. var scope = ops.name_scope(_name_scope());
  16. scope.__enter__();
  17. MaybeBuild(inputs);
  18. // Wrapping `call` function in autograph to allow for dynamic control
  19. // flow and control dependencies in call. We are limiting this to
  20. // subclassed layers as autograph is strictly needed only for
  21. // subclassed layers and models.
  22. // tf_convert will respect the value of autograph setting in the
  23. // enclosing tf.function, if any.
  24. if (!dynamic)
  25. throw new NotImplementedException("");
  26. outputs = Call(inputs);
  27. _set_connectivity_metadata_(inputs, outputs);
  28. _handle_activity_regularization(inputs, outputs);
  29. _set_mask_metadata(inputs, outputs, null);
  30. scope.__exit__();
  31. graph.Exit();
  32. return outputs;
  33. }
  34. }
  35. }