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.

keras.layers.cs 1.4 kB

6 years ago
6 years ago
6 years ago
6 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Tensorflow.Keras;
  6. using Tensorflow.Keras.Engine;
  7. using Tensorflow.Keras.Layers;
  8. namespace Tensorflow
  9. {
  10. public static partial class keras
  11. {
  12. public static class layers
  13. {
  14. public static Embedding Embedding(int input_dim, int output_dim,
  15. IInitializer embeddings_initializer = null,
  16. bool mask_zero = false) => new Embedding(input_dim, output_dim,
  17. embeddings_initializer,
  18. mask_zero);
  19. public static Tensor[] Input(int[] batch_shape = null,
  20. TF_DataType dtype = TF_DataType.DtInvalid,
  21. string name = null,
  22. bool sparse = false,
  23. Tensor tensor = null)
  24. {
  25. var batch_size = batch_shape[0];
  26. var shape = batch_shape.Skip(1).ToArray();
  27. var input_layer = new InputLayer(
  28. input_shape: shape,
  29. batch_size: batch_size,
  30. name: name,
  31. dtype: dtype,
  32. sparse: sparse,
  33. input_tensor: tensor);
  34. var outputs = input_layer.inbound_nodes[0].output_tensors;
  35. return outputs;
  36. }
  37. }
  38. }
  39. }

tensorflow框架的.NET版本,提供了丰富的特性和API,可以借此很方便地在.NET平台下搭建深度学习训练与推理流程。