提交 53e697c1 编写于 作者: F fengjiayi

refine code

上级 3dfd1da1
...@@ -66,9 +66,8 @@ class RandomReader : public FileReader { ...@@ -66,9 +66,8 @@ class RandomReader : public FileReader {
public: public:
RandomReader(const std::vector<DDim>& shapes, float min, float max) RandomReader(const std::vector<DDim>& shapes, float min, float max)
: FileReader(shapes), min_(min), max_(max) { : FileReader(shapes), min_(min), max_(max) {
PADDLE_ENFORCE_LE(min, max, PADDLE_ENFORCE_LE(
"'min' should be less than or equal to 'max'.(%f vs %f)", min, max, "'min' shouldn't be greater than 'max'.(%f vs %f)", min, max);
min, max);
unsigned int seed = std::random_device()(); unsigned int seed = std::random_device()();
engine_.seed(seed); engine_.seed(seed);
dist_ = std::uniform_real_distribution<float>(min_, max_); dist_ = std::uniform_real_distribution<float>(min_, max_);
...@@ -103,7 +102,7 @@ class RandomReader : public FileReader { ...@@ -103,7 +102,7 @@ class RandomReader : public FileReader {
std::uniform_real_distribution<float> dist_; std::uniform_real_distribution<float> dist_;
}; };
// decorators // decorated readers
class ShuffleReader : public DecoratedReader { class ShuffleReader : public DecoratedReader {
public: public:
...@@ -134,6 +133,8 @@ class BatchReader : public DecoratedReader { ...@@ -134,6 +133,8 @@ class BatchReader : public DecoratedReader {
std::vector<std::vector<LoDTensor>> buffer_; std::vector<std::vector<LoDTensor>> buffer_;
}; };
// The ReaderHolder is used as readers' unified wrapper,
// making it easier to access different type readers in Variables.
class ReaderHolder { class ReaderHolder {
public: public:
void Reset(ReaderBase* reader) { reader_.reset(reader); } void Reset(ReaderBase* reader) { reader_.reset(reader); }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册