dfalbel / torch

torch from R!
http://dfalbel.github.io/torch
Other
50 stars 5 forks source link

Tensor tch functions #28

Closed Athospd closed 5 years ago

Athospd commented 5 years ago

tch functions implemented:

Methods:

tch functions that I failed to implement:

Notes:

  // TODO handle other sum arguments.
  Rcpp::stop("Not yet implemented");
dfalbel commented 5 years ago

@Athospd I think it didn't work median and mode, because when you have a dim argument median will return 2 tensors: the medians for each row and the index of the median for each row.

In this case I think we will need 2 functions: 1 to calculate the median (without any additional args) and another to calculate the median with and return both tensors to R. tensor_qr_ has a reference implementation for this. Then we need to create some glue code on the R side.

dfalbel commented 5 years ago

@Athospd I created a reference implementation for tch_mean here: https://github.com/dfalbel/torch/blob/4bd94ae7db65f0dbf0308e1cca892eec359f13a0/src/tensor.cpp#L1037-L1049

We need to adapt other functions that have this kind of behavior to use this.

Athospd commented 5 years ago

@dfalbel I found out that the following functions has the tuple (dim, keepdim) args:

argmax argmin logsumexp median mode norm prod std sum var kthvalue max min

We have to adapt these using mean as reference, I got it right?

dfalbel commented 5 years ago

Exactly!

dfalbel commented 5 years ago

I will close this PR and merge #31 .