Comments (7)
You can not direct read scalar from GPU tensor. Currently, one thing you can possibly do is store the result to a Tensor2D and copy to CPU to read it. There was a performance reason why we did not support summing over all the elements in GPU.
If you are implementing neural nets, usually copy to CPU to evaluate the statistics won't harm the overall performance, because this was a cheap operation
from mshadow.
Hi tq,
Actually I am only going to do this on CPU, so do you suggest I should just do thing like this?
for(unsigned int i = 0 ; i < outgrad.shape[1] ; i ++){
for(unsigned int j = 0 ; j < outgrad.shape[2] ; j ++){
err += outgrad[i][j] * outgrad[i][j];
}
}
Thanks a lot !
from mshadow.
If it was a 2D tensor, remember C++ index starts from 0, so it should be shape[1] and shape[0].. If you use master version of mshadow.
for(unsigned int i = 0 ; i < outgrad.size(0) ; i ++){
for(unsigned int j = 0 ; j < outgrad.size(1) ; j ++){
err += outgrad[i][j] * outgrad[i][j];
}
}
The shape convention in master was reversed from numpy and a bit weird. There is going to be a major refactor to solve the problem
from mshadow.
so shape[0] is the number of columns in a 2D tensor
and shape[1] is the number of rows, Is this correct ? What if we have a 3D Tensor ?
I am kind of confused by this phrase in the tutorial:
"shape_[0] gives the lowest dimension, shape_[1] gives the second dimension, etc. This is different from numpy."
what does it mean by "the lowest dimension"
Thanks!
from mshadow.
Sorry about the confusion, this is a deprecated convention that will be changed. For temporal solution, you can use tensor.size(i), updated in master, which follows the same convention as numpy. I have updated the example
from mshadow.
Got it.
Thanks !
from mshadow.
you are welcome
from mshadow.
Related Issues (20)
- About getting the shape of a tensor HOT 1
- [please delete]
- how to reduce a one-dimension tensor (vector) ? HOT 1
- why there is no kDim inference check in ExpInfo for TenaryMapExp? HOT 1
- Is this a bug of operator[] ?
- mac make errors HOT 1
- Error on compiling basic_stream.cu with CUDA 9.0 HOT 3
- Shall we add half_t support to Random<cpu, DType> HOT 2
- --start-group not supported by macOS HOT 2
- Support for Complex numbers HOT 2
- Row wise normalization of tensor HOT 1
- [Clarification] Provision for AMD HIP backend for MXNet HOT 1
- dot_engine-inl.h MSHADOW_STAND_ALONE BLASEngine<cpu, float>::gemm error HOT 1
- error: no instance of function template "mshadow::Random<mshadow::gpu, DType>::SampleUniform
- CI is failing HOT 1
- Add Scientific Linux to makefile's CentOS blas library exception HOT 1
- Is 'base.h:173:20:fatal error: cuda.h: No such file or directory' means I did't install cuda? HOT 2
- does there need some update with guide and tests? HOT 1
- [RFC] Deprecate mshadow and donate code to apache-mxnet HOT 13
- Doesn't install any files HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mshadow.