New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added the discretize function. Design changes as discussed. #703
Closed
Closed
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
b38b688
edge_boxes: feature extraction updated, tests added
nilayjain 6e1740b
not working right now
nilayjain 5bab953
working on it
b506eea
added discretize function
nilayjain f788f97
added discretize function
49c25fe
fixed unintended changes
9399cd3
backported index_min and index_max
0abec2c
added some timers for analysis
nilayjain 987f079
added IndexMin function
nilayjain f041da4
timing tests, computing gradient by sobel filter
nilayjain 08bd550
timing tests, computing gradient by sobel filter
nilayjain 2f8f3c7
more comments need to be added
e9987d9
comments
72eb1ef
incorporated fixes, added comments in PrepareData
nilayjain File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ set(DIRS | |
det | ||
emst | ||
edge_boxes | ||
fastmks | ||
# fastmks | ||
gmm | ||
hmm | ||
hoeffding_trees | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,8 +24,53 @@ StructuredForests(FeatureParameters F) | |
params = F; | ||
} | ||
|
||
/* | ||
template<typename MatType, typename CubeType> | ||
MatType StructuredForests<MatType, CubeType>:: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess we can remove useless codes, let git help us memorize the codes we written |
||
LoadData(MatType const &Images, MatType const &boundaries,\ | ||
MatType const &segmentations) | ||
{ | ||
const size_t num_Images = this->params.num_Images; | ||
const size_t rowSize = this->params.RowSize(); | ||
const size_t colSize = this->params.ColSize(); | ||
MatType input_data(num_Images * rowSize * 5, colSize); | ||
// we store the input data as follows: | ||
// Images (3), boundaries (1), segmentations (1). | ||
size_t loop_iter = num_Images * 5; | ||
size_t row_idx = 0; | ||
size_t col_i = 0, col_s = 0, col_b = 0; | ||
for(size_t i = 0; i < loop_iter; ++i) | ||
{ | ||
if (i % 5 == 4) | ||
{ | ||
input_data.submat(row_idx, 0, row_idx + rowSize - 1,\ | ||
colSize - 1) = MatType(segmentations.colptr(col_s),\ | ||
colSize, rowSize).t(); | ||
++col_s; | ||
} | ||
else if (i % 5 == 3) | ||
{ | ||
input_data.submat(row_idx, 0, row_idx + rowSize - 1,\ | ||
colSize - 1) = MatType(boundaries.colptr(col_b),\ | ||
colSize, rowSize).t(); | ||
++col_b; | ||
} | ||
else | ||
{ | ||
input_data.submat(row_idx, 0, row_idx + rowSize - 1,\ | ||
colSize - 1) = MatType(Images.colptr(col_i), | ||
colSize, rowSize).t(); | ||
++col_i; | ||
} | ||
row_idx += rowSize; | ||
} | ||
return input_data; | ||
} | ||
|
||
*/ | ||
|
||
/** | ||
* Get Dimensions of Features | ||
* Get DImensions of Features | ||
* @param FtrDim Output vector that contains the result | ||
*/ | ||
template<typename MatType, typename CubeType> | ||
|
@@ -804,7 +849,7 @@ PrepareData(const MatType& Images, const MatType& Boundaries,\ | |
const size_t nFtrDim = FtrDim(0) + FtrDim(1); | ||
const size_t nSmpFtrDim = (size_t)(nFtrDim * fraction); | ||
|
||
|
||
size_t time=0; | ||
for(size_t i = 0; i < numTree; ++i) | ||
{ | ||
//Implement the logic for if data already exists. | ||
|
@@ -892,7 +937,11 @@ PrepareData(const MatType& Images, const MatType& Boundaries,\ | |
} | ||
|
||
CubeType SSFtr, RegFtr; | ||
Timer::Start("get_features"); | ||
|
||
this->GetFeatures(Img, loc, RegFtr, SSFtr, table); | ||
Timer::Stop("get_features"); | ||
|
||
//randomly sample 70 values each from reg_ftr and ss_ftr. | ||
/* | ||
CubeType ftr(140, 1000, 13); | ||
|
@@ -907,7 +956,7 @@ PrepareData(const MatType& Images, const MatType& Boundaries,\ | |
// have to do this or we can overload the CopyMakeBorder to support MatType. | ||
s.slice(0) = segs; | ||
CubeType in_segs; | ||
this->CopyMakeBorder(s, gRad, gRad, gRad, | ||
this->CopyMakeBorder(s, gRad, gRad, gRad,\ | ||
gRad, in_segs); | ||
|
||
for(size_t i = 0; i < loc.n_rows; ++i) | ||
|
@@ -935,6 +984,7 @@ Discretize(const MatType& labels, const size_t nClass,\ | |
// lbls : 20000 * 256. | ||
// nSample: number of samples for clustering structured labels 256 | ||
// nClass: number of classes (clusters) for binary splits. 2 | ||
Timer::Start("other_discretize"); | ||
|
||
arma::uvec lis1(nSample); | ||
for (size_t i = 0; i < lis1.n_elem; ++i) | ||
|
@@ -967,14 +1017,21 @@ Discretize(const MatType& labels, const size_t nClass,\ | |
// so most representative label is: labels.row(ind). | ||
|
||
// apply pca | ||
Timer::Stop("other_discretize"); | ||
Timer::Start("pca_timer"); | ||
MatType coeff, transformedData; | ||
arma::vec eigVal; | ||
mlpack::pca::PCA p; | ||
p.Apply(zs.t(), transformedData, eigVal, coeff); | ||
// we take only first row in transformedData (256 * 20000) as dim = 1. | ||
Timer::Stop("pca_timer"); | ||
Timer::Start("other_discretize"); | ||
//std::cout << Timer::Get("pca_timer") << std::endl; | ||
DiscreteLabels = arma::conv_to<arma::vec>::from(transformedData.row(0).t() > 0); | ||
Timer::Stop("other_discretize"); | ||
} | ||
return ind; | ||
|
||
} | ||
} // namespace structured_tree | ||
} // namespace mlpack | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we do not need the codes again, I think we can remove it, git will record the codes we removed before, when we need them again, we can use git to check it out