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.

Numpy.Creation.cs 2.1 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Numerics;
  5. using System.Text;
  6. using static Tensorflow.Binding;
  7. namespace Tensorflow.NumPy
  8. {
  9. public partial class np
  10. {
  11. public static NDArray array(Array data)
  12. => new NDArray(data);
  13. public static NDArray array<T>(params T[] data)
  14. where T : unmanaged
  15. => new NDArray(data);
  16. public static NDArray arange<T>(T end)
  17. where T : unmanaged
  18. => new NDArray(tf.range(default(T), limit: end));
  19. public static NDArray arange<T>(T start, T? end = null, T? step = null)
  20. where T : unmanaged
  21. => new NDArray(tf.range(start, limit: end, delta: step));
  22. public static NDArray empty(Shape shape, TF_DataType dtype = TF_DataType.TF_DOUBLE)
  23. => new NDArray(tf.zeros(shape, dtype: dtype));
  24. public static NDArray eye(int N, int? M = null, int k = 0, TF_DataType dtype = TF_DataType.TF_DOUBLE)
  25. => tf.numpy.eye(N, M: M, k: k, dtype: dtype);
  26. public static NDArray full<T>(Shape shape, T fill_value)
  27. => new NDArray(tf.fill(tf.constant(shape), fill_value));
  28. public static NDArray linspace<T>(T start, T stop, int num = 50, bool endpoint = true, bool retstep = false,
  29. TF_DataType dtype = TF_DataType.TF_DOUBLE, int axis = 0) where T : unmanaged
  30. => tf.numpy.linspace(start, stop, num: num, endpoint: endpoint, retstep: retstep, dtype: dtype, axis: axis);
  31. public static (NDArray, NDArray) meshgrid<T>(T x, T y, bool copy = true, bool sparse = false)
  32. => tf.numpy.meshgrid(new[] { x, y }, copy: copy, sparse: sparse);
  33. public static NDArray ones(Shape shape, TF_DataType dtype = TF_DataType.TF_DOUBLE)
  34. => new NDArray(tf.ones(shape, dtype: dtype));
  35. public static NDArray ones_like(NDArray a, Type dtype = null)
  36. => throw new NotImplementedException("");
  37. public static NDArray zeros(Shape shape, TF_DataType dtype = TF_DataType.TF_DOUBLE)
  38. => new NDArray(tf.zeros(shape, dtype: dtype));
  39. }
  40. }