virtual void SetUp() { Caffe::set_random_seed(1601); vector<int> shape1, shape2; shape1.push_back(NUM); shape1.push_back(CHENNAL); shape1.push_back(HEIGHT); shape1.push_back(WIDTH); shape2.push_back(NUM); shape2.push_back(1); shape2.push_back(1); shape2.push_back(1); blob_bottom1_->Reshape(shape1); blob_bottom2_->Reshape(shape2); // fill the values FillerParameter filler_param; GaussianFiller<Dtype> filler1(filler_param); GaussianFiller<Dtype> filler2(filler_param); filler1.Fill(this->blob_bottom1_); for (int i = 0; i < NUM; ++i){ blob_bottom2_->mutable_cpu_data()[i] = caffe_rng_rand() % 2; } for (int i = 0; i < NUM; ++i){ for (int j = 0; j < CHENNAL * HEIGHT * WIDTH; ++j){ int idx = i * CHENNAL * HEIGHT * WIDTH + j; blob_bottom1_->mutable_cpu_data()[idx] = i * 10; } } blob_bottom_vec_.push_back(blob_bottom1_); blob_bottom_vec_.push_back(blob_bottom2_); blob_top_vec_.push_back(blob_top_); }
bool Validator::ValidateBoards(const std::vector<Pos> & board1, const std::vector<Pos> & board2, const std::pair<int, int> & dimensions) { Filler filler1(board1, dimensions.first, dimensions.second); Filler filler2(board2, dimensions.first, dimensions.second); for (std::size_t i = 0, len = board1.size(); i < len; ++i) { std::unordered_set<int> cluster_board1; filler1.GetCluster(board1[i], cluster_board1); std::unordered_set<int> cluster_board2; filler2.GetCluster(board2[i], cluster_board2); if (!ValidateClusters(cluster_board1, cluster_board2)) { return false; } } return true; }