HDF5_DATA + MEMORY_DATA refuse loudly to transform#1841
Conversation
These layers are meant for generic inputs so they do not do transformations. As `transform_param` was pulled out of data layers' proto definitions for reuse, these layers silently ignored transformation parameters until now instead of signalling their refusal.
fcccc2a to
56846e6
Compare
|
I can create PR with transforms for memory_data, do you need that ? |
HDF5_DATA + MEMORY_DATA refuse loudly to transform
|
@DmitryUlyanov if extending @longjon thoughts? |
|
@shelhamer well, I don't actually think It's a good way to transform things when doing reset (or Add...Vector) because during training you obviously want to have some random transformations every time. So I did it in void MemoryDataLayer<Dtype>::Forward_cpu(const vector<Blob<Dtype>*>& bottom,
const vector<Blob<Dtype>*>& top) {
CHECK(data_) << "MemoryDataLayer needs to be initalized by calling Reset";
if (this->layer_param_.has_transform_param()) {
// Copy to blob
Blob<Dtype> b;
b.Reshape(batch_size_, channels_, height_, width_);
b.set_cpu_data(data_ + pos_ * size_);
// transform
this->data_transformer_.Transform(&b, top[0]);
// Copy labels
top[1]->set_cpu_data(labels_ + pos_);
} else {
top[0]->set_cpu_data(data_ + pos_ * size_);
top[1]->set_cpu_data(labels_ + pos_);
}
pos_ = (pos_ + batch_size_) % n_;
has_new_data_ = false;
}And anyway user can omit transform_params in config so memory_data will take input arrays exactly as they are with no overhead at all. |
|
Even with MemoryDataLayer, I use the prototxt to specify what transform parameters to use (in |
|
This check was accidentally too stringent for (While transforming during forward isn't ideal it's the best solution at present.) |
These layers are meant for generic inputs so they do not do transformations. As
transform_paramwas pulled out of data layers' proto definitions for reuse, these layers silently ignored transformation parameters until now instead of signalling their refusal.Transforming could be added in a future PR. Better to make sure users know the current state first.
See #1718.