• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2021 Huawei Technologies Co., Ltd
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #include <sys/stat.h>
17 #include <unistd.h>
18 #include <map>
19 #include <memory>
20 #include <set>
21 #include <string>
22 #include <unordered_map>
23 #include <unordered_set>
24 #include <utility>
25 #include <vector>
26 
27 #include "include/dataset/datasets.h"
28 #include "include/dataset/iterator.h"
29 #include "include/dataset/vision_lite.h"
30 #include "include/dataset/transforms.h"
31 #include "include/api/types.h"
32 
33 using mindspore::dataset::Dataset;
34 using mindspore::dataset::Iterator;
35 using mindspore::dataset::Mnist;
36 using mindspore::dataset::TensorTransform;
37 
main(int argc,char ** argv)38 int main(int argc, char **argv) {
39   std::string folder_path = "./testMnistData/";
40   std::shared_ptr<Dataset> ds = Mnist(folder_path, "all");
41 
42   std::shared_ptr<TensorTransform> resize(new mindspore::dataset::vision::Resize({32, 32}));
43   ds = ds->Map({resize});
44 
45   ds = ds->Shuffle(2);
46   ds = ds->Batch(2);
47 
48   std::shared_ptr<Iterator> iter = ds->CreateIterator();
49 
50   std::unordered_map<std::string, mindspore::MSTensor> row;
51   iter->GetNextRow(&row);
52 
53   while (row.size() != 0) {
54     iter->GetNextRow(&row);
55   }
56 
57   iter->Stop();
58 }
59