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.8 kB

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