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.

backbone.cs 2.6 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using Tensorflow;
  5. using static Tensorflow.Binding;
  6. namespace TensorFlowNET.Examples.ImageProcessing.YOLO
  7. {
  8. class backbone
  9. {
  10. public static (Tensor, Tensor, Tensor) darknet53(Tensor input_data, Tensor trainable)
  11. {
  12. return tf_with(tf.variable_scope("darknet"), scope =>
  13. {
  14. input_data = common.convolutional(input_data, filters_shape: new int[] { 3, 3, 3, 32 }, trainable: trainable, name: "conv0");
  15. input_data = common.convolutional(input_data, filters_shape: new int[] { 3, 3, 32, 64 }, trainable: trainable, name: "conv1", downsample: true);
  16. foreach (var i in range(1))
  17. input_data = common.residual_block(input_data, 64, 32, 64, trainable: trainable, name: $"residual{i + 0}");
  18. input_data = common.convolutional(input_data, filters_shape: new[] { 3, 3, 64, 128 },
  19. trainable: trainable, name: "conv4", downsample: true);
  20. foreach (var i in range(2))
  21. input_data = common.residual_block(input_data, 128, 64, 128, trainable: trainable, name: $"residual{i + 1}");
  22. input_data = common.convolutional(input_data, filters_shape: new[] { 3, 3, 128, 256 },
  23. trainable: trainable, name: "conv9", downsample: true);
  24. foreach (var i in range(8))
  25. input_data = common.residual_block(input_data, 256, 128, 256, trainable: trainable, name: $"residual{i + 3}");
  26. var route_1 = input_data;
  27. input_data = common.convolutional(input_data, filters_shape: new int[] { 3, 3, 256, 512 },
  28. trainable: trainable, name: "conv26", downsample: true);
  29. foreach (var i in range(8))
  30. input_data = common.residual_block(input_data, 512, 256, 512, trainable: trainable, name: $"residual{i + 11}");
  31. var route_2 = input_data;
  32. input_data = common.convolutional(input_data, filters_shape: new[] { 3, 3, 512, 1024 },
  33. trainable: trainable, name: "conv43", downsample: true);
  34. foreach (var i in range(4))
  35. input_data = common.residual_block(input_data, 1024, 512, 1024, trainable: trainable, name: $"residual{i + 19}");
  36. return (route_1, route_2, input_data);
  37. });
  38. }
  39. }
  40. }