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.

tf.sparse.cs 2.5 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*****************************************************************************
  2. Copyright 2018 The TensorFlow.NET Authors. All Rights Reserved.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ******************************************************************************/
  13. using Tensorflow.Framework;
  14. namespace Tensorflow
  15. {
  16. public partial class tensorflow
  17. {
  18. public SparseTensor<T> SparseTensor<T>(long[,] indices, T[] values, long[] dense_shape)
  19. => new SparseTensor<T>(indices, values, dense_shape);
  20. public Tensor sparse_tensor_to_dense<T>(SparseTensor<T> sp_input,
  21. T default_value = default,
  22. bool validate_indices = true,
  23. string name = null)
  24. => gen_sparse_ops.sparse_to_dense(sp_input.indices,
  25. sp_input.dense_shape,
  26. sp_input.values,
  27. default_value: default_value,
  28. validate_indices: validate_indices,
  29. name: name);
  30. /// <summary>
  31. /// Converts a sparse representation into a dense tensor.
  32. /// </summary>
  33. /// <typeparam name="T"></typeparam>
  34. /// <param name="sparse_indices"></param>
  35. /// <param name="output_shape"></param>
  36. /// <param name="sparse_values"></param>
  37. /// <param name="default_value"></param>
  38. /// <param name="validate_indices"></param>
  39. /// <param name="name"></param>
  40. /// <returns>Dense `Tensor` of shape `output_shape`. Has the same type as `sparse_values`.</returns>
  41. public Tensor sparse_to_dense<T>(Tensor sparse_indices,
  42. TensorShape output_shape,
  43. T sparse_values,
  44. T default_value = default,
  45. bool validate_indices = true,
  46. string name = null)
  47. => gen_sparse_ops.sparse_to_dense(sparse_indices,
  48. output_shape,
  49. sparse_values,
  50. default_value: default_value,
  51. validate_indices: validate_indices,
  52. name: name);
  53. }
  54. }