{"action":"created","comment":{"url":"https://api.github.com/repos/mlpack/mlpack/pulls/comments/66461709","id":66461709,"diff_hunk":"@@ -0,0 +1,903 @@\n+/**\n+ * @file feature_extraction_impl.hpp\n+ * @author Nilay Jain\n+ *\n+ * Implementation of feature extraction methods.\n+ */\n+#ifndef MLPACK_METHODS_EDGE_BOXES_STRUCTURED_TREE_IMPL_HPP\n+#define MLPACK_METHODS_EDGE_BOXES_STRUCTURED_TREE_IMPL_HPP\n+\n+\n+#include \"feature_extraction.hpp\"\n+#include <map>\n+\n+namespace mlpack {\n+namespace structured_tree {\n+\n+template<typename MatType, typename CubeType>\n+StructuredForests<MatType, CubeType>::\n+StructuredForests(const std::map<std::string, int>& inMap)\n+{\n+  this->options = inMap;\n+}\n+\n+template<typename MatType, typename CubeType>\n+MatType StructuredForests<MatType, CubeType>::\n+LoadData(MatType& images, MatType& boundaries, MatType& segmentations)\n+{\n+  int num_images = this->options[\"num_images\"];\n+  int row_size = this->options[\"row_size\"];\n+  int col_size = this->options[\"col_size\"];\n+  MatType input_data(num_images * row_size * 5, col_size);\n+  // we store the input data as follows: \n+  // images (3), boundaries (1), segmentations (1).\n+  int loop_iter = num_images * 5;\n+  size_t row_idx = 0;\n+  int col_i = 0, col_s = 0, col_b = 0;\n+  for(size_t i = 0; i < loop_iter; ++i)\n+  {\n+    if (i % 5 == 4)\n+    {\n+      input_data.submat(row_idx, 0, row_idx + row_size - 1,\\\n+        col_size - 1) = MatType(segmentations.colptr(col_s),\\\n+                                  col_size, row_size).t();\n+      ++col_s;\n+    }\n+    else if (i % 5 == 3)\n+    {\n+      input_data.submat(row_idx, 0, row_idx + row_size - 1,\\\n+        col_size - 1) = MatType(boundaries.colptr(col_b),\\\n+                                  col_size, row_size).t();\n+      ++col_b;\n+    }\n+    else\n+    {\n+      input_data.submat(row_idx, 0, row_idx + row_size - 1,\\\n+        col_size - 1) = MatType(images.colptr(col_i),\n+                                  col_size, row_size).t();\n+      ++col_i;  \n+    }\n+    row_idx += row_size;\n+  }\n+  return input_data;\n+} \n+\n+template<typename MatType, typename CubeType>\n+arma::vec StructuredForests<MatType, CubeType>::\n+GetFeatureDimension()\n+{\n+  /*\n+  shrink: amount to shrink channels\n+  p_size: size of image patches\n+  n_cell: number of self similarity cells\n+  n_orient: number of orientations per gradient scale\n+  */\n+  arma::vec P(2);\n+  int shrink, p_size, n_cell;\n+  shrink = this->options[\"shrink\"];\n+  p_size = this->options[\"p_size\"];\n+  n_cell = this->options[\"n_cell\"];\n+\n+  /*\n+  n_color_ch: number of color channels\n+  n_grad_ch: number of gradient channels\n+  n_ch: total number of channels\n+  */\n+  int n_color_ch, n_grad_ch, n_ch;\n+  if (this->options[\"rgbd\"] == 0)\n+    n_color_ch = 3;\n+  else\n+    n_color_ch = 4;\n+\n+  n_grad_ch = 2 * (1 + this->options[\"n_orient\"]);\n+\n+  n_ch = n_color_ch + n_grad_ch;\n+  P[0] = pow((p_size / shrink) , 2) * n_ch;\n+  P[1] = pow(n_cell , 2) * (pow (n_cell, 2) - 1) / 2 * n_ch;\n+  return P;\n+}\n+\n+template<typename MatType, typename CubeType>\n+arma::vec StructuredForests<MatType, CubeType>::\n+dt_1d(arma::vec& f, int n)\n+{\n+  arma::vec d(n), v(n), z(n + 1);\n+  int k = 0;\n+  v[0] = 0.0;\n+  z[0] = -INF;\n+  z[1] = +INF;\n+  for (size_t q = 1; q <= n - 1; ++q)\n+  {\n+    float s  = ( (f[q] + q * q)-( f[v[k]] + v[k] * v[k]) ) / (2 * q - 2 * v[k]);\n+    while (s <= z[k])\n+    {\n+      --k;\n+      s  = ( (f[q] + q * q) - (f[v[k]] + v[k] * v[k]) ) / (2 * q - 2 * v[k]);\n+    }\n+\n+    k++;\n+    v[k] = (double)q;\n+    z[k] = s;\n+    z[k+1] = +INF;\n+  }\n+\n+  k = 0;\n+  for (int q = 0; q <= n-1; q++)\n+  {\n+    while (z[k+1] < q)\n+      k++;\n+    d[q] = (q - v[k]) * (q - v[k]) + f[v[k]];\n+  }\n+  return d;\n+}\n+\n+template<typename MatType, typename CubeType>\n+void StructuredForests<MatType, CubeType>::\n+dt_2d(MatType& im)\n+{\n+  arma::vec f(std::max(im.n_rows, im.n_cols));\n+  // transform along columns\n+  for (size_t x = 0; x < im.n_cols; ++x)\n+  {\n+    f.subvec(0, im.n_rows - 1) = im.col(x);\n+    arma::vec d = this->dt_1d(f, im.n_rows);\n+    im.col(x) = d;\n+  }\n+\n+  // transform along rows\n+  for (int y = 0; y < im.n_rows; y++)","path":"src/mlpack/methods/edge_boxes/feature_extraction_impl.hpp","position":null,"original_position":148,"commit_id":"05fcf0bc43f6ee18cbccca8c5558197b2c50f511","original_commit_id":"9d85b64c6c6bdff608331195351d09abf56cfc96","user":{"login":"stereomatchingkiss","id":1801914,"avatar_url":"https://avatars.githubusercontent.com/u/1801914?v=3","gravatar_id":"","url":"https://api.github.com/users/stereomatchingkiss","html_url":"https://github.com/stereomatchingkiss","followers_url":"https://api.github.com/users/stereomatchingkiss/followers","following_url":"https://api.github.com/users/stereomatchingkiss/following{/other_user}","gists_url":"https://api.github.com/users/stereomatchingkiss/gists{/gist_id}","starred_url":"https://api.github.com/users/stereomatchingkiss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stereomatchingkiss/subscriptions","organizations_url":"https://api.github.com/users/stereomatchingkiss/orgs","repos_url":"https://api.github.com/users/stereomatchingkiss/repos","events_url":"https://api.github.com/users/stereomatchingkiss/events{/privacy}","received_events_url":"https://api.github.com/users/stereomatchingkiss/received_events","type":"User","site_admin":false},"body":"I guess this line would emit warning(compare with unsigned and signed, change y to size_t or uword may solve this problem, I remember rcurtin prefer size_t since it is a standard way to store the size of array)","created_at":"2016-06-09T15:20:41Z","updated_at":"2016-06-09T15:20:41Z","html_url":"https://github.com/mlpack/mlpack/pull/683#discussion_r66461709","pull_request_url":"https://api.github.com/repos/mlpack/mlpack/pulls/683","_links":{"self":{"href":"https://api.github.com/repos/mlpack/mlpack/pulls/comments/66461709"},"html":{"href":"https://github.com/mlpack/mlpack/pull/683#discussion_r66461709"},"pull_request":{"href":"https://api.github.com/repos/mlpack/mlpack/pulls/683"}}},"pull_request":{"url":"https://api.github.com/repos/mlpack/mlpack/pulls/683","id":72779146,"html_url":"https://github.com/mlpack/mlpack/pull/683","diff_url":"https://github.com/mlpack/mlpack/pull/683.diff","patch_url":"https://github.com/mlpack/mlpack/pull/683.patch","issue_url":"https://api.github.com/repos/mlpack/mlpack/issues/683","number":683,"state":"closed","locked":false,"title":"backported ind2sub and sub2ind.","user":{"login":"nilayjain","id":10858890,"avatar_url":"https://avatars.githubusercontent.com/u/10858890?v=3","gravatar_id":"","url":"https://api.github.com/users/nilayjain","html_url":"https://github.com/nilayjain","followers_url":"https://api.github.com/users/nilayjain/followers","following_url":"https://api.github.com/users/nilayjain/following{/other_user}","gists_url":"https://api.github.com/users/nilayjain/gists{/gist_id}","starred_url":"https://api.github.com/users/nilayjain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nilayjain/subscriptions","organizations_url":"https://api.github.com/users/nilayjain/orgs","repos_url":"https://api.github.com/users/nilayjain/repos","events_url":"https://api.github.com/users/nilayjain/events{/privacy}","received_events_url":"https://api.github.com/users/nilayjain/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-06-06T21:14:27Z","updated_at":"2016-06-09T15:20:41Z","closed_at":"2016-06-07T20:47:05Z","merged_at":"2016-06-07T20:47:05Z","merge_commit_sha":"b29bad9f77af89306ba48fb918c7772b72f19eac","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mlpack/mlpack/pulls/683/commits","review_comments_url":"https://api.github.com/repos/mlpack/mlpack/pulls/683/comments","review_comment_url":"https://api.github.com/repos/mlpack/mlpack/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mlpack/mlpack/issues/683/comments","statuses_url":"https://api.github.com/repos/mlpack/mlpack/statuses/05fcf0bc43f6ee18cbccca8c5558197b2c50f511","head":{"label":"nilayjain:work","ref":"work","sha":"05fcf0bc43f6ee18cbccca8c5558197b2c50f511","user":{"login":"nilayjain","id":10858890,"avatar_url":"https://avatars.githubusercontent.com/u/10858890?v=3","gravatar_id":"","url":"https://api.github.com/users/nilayjain","html_url":"https://github.com/nilayjain","followers_url":"https://api.github.com/users/nilayjain/followers","following_url":"https://api.github.com/users/nilayjain/following{/other_user}","gists_url":"https://api.github.com/users/nilayjain/gists{/gist_id}","starred_url":"https://api.github.com/users/nilayjain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nilayjain/subscriptions","organizations_url":"https://api.github.com/users/nilayjain/orgs","repos_url":"https://api.github.com/users/nilayjain/repos","events_url":"https://api.github.com/users/nilayjain/events{/privacy}","received_events_url":"https://api.github.com/users/nilayjain/received_events","type":"User","site_admin":false},"repo":{"id":60458495,"name":"mlpack","full_name":"nilayjain/mlpack","owner":{"login":"nilayjain","id":10858890,"avatar_url":"https://avatars.githubusercontent.com/u/10858890?v=3","gravatar_id":"","url":"https://api.github.com/users/nilayjain","html_url":"https://github.com/nilayjain","followers_url":"https://api.github.com/users/nilayjain/followers","following_url":"https://api.github.com/users/nilayjain/following{/other_user}","gists_url":"https://api.github.com/users/nilayjain/gists{/gist_id}","starred_url":"https://api.github.com/users/nilayjain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nilayjain/subscriptions","organizations_url":"https://api.github.com/users/nilayjain/orgs","repos_url":"https://api.github.com/users/nilayjain/repos","events_url":"https://api.github.com/users/nilayjain/events{/privacy}","received_events_url":"https://api.github.com/users/nilayjain/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nilayjain/mlpack","description":"mlpack: a scalable C++ machine learning library","fork":true,"url":"https://api.github.com/repos/nilayjain/mlpack","forks_url":"https://api.github.com/repos/nilayjain/mlpack/forks","keys_url":"https://api.github.com/repos/nilayjain/mlpack/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nilayjain/mlpack/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nilayjain/mlpack/teams","hooks_url":"https://api.github.com/repos/nilayjain/mlpack/hooks","issue_events_url":"https://api.github.com/repos/nilayjain/mlpack/issues/events{/number}","events_url":"https://api.github.com/repos/nilayjain/mlpack/events","assignees_url":"https://api.github.com/repos/nilayjain/mlpack/assignees{/user}","branches_url":"https://api.github.com/repos/nilayjain/mlpack/branches{/branch}","tags_url":"https://api.github.com/repos/nilayjain/mlpack/tags","blobs_url":"https://api.github.com/repos/nilayjain/mlpack/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nilayjain/mlpack/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nilayjain/mlpack/git/refs{/sha}","trees_url":"https://api.github.com/repos/nilayjain/mlpack/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nilayjain/mlpack/statuses/{sha}","languages_url":"https://api.github.com/repos/nilayjain/mlpack/languages","stargazers_url":"https://api.github.com/repos/nilayjain/mlpack/stargazers","contributors_url":"https://api.github.com/repos/nilayjain/mlpack/contributors","subscribers_url":"https://api.github.com/repos/nilayjain/mlpack/subscribers","subscription_url":"https://api.github.com/repos/nilayjain/mlpack/subscription","commits_url":"https://api.github.com/repos/nilayjain/mlpack/commits{/sha}","git_commits_url":"https://api.github.com/repos/nilayjain/mlpack/git/commits{/sha}","comments_url":"https://api.github.com/repos/nilayjain/mlpack/comments{/number}","issue_comment_url":"https://api.github.com/repos/nilayjain/mlpack/issues/comments{/number}","contents_url":"https://api.github.com/repos/nilayjain/mlpack/contents/{+path}","compare_url":"https://api.github.com/repos/nilayjain/mlpack/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nilayjain/mlpack/merges","archive_url":"https://api.github.com/repos/nilayjain/mlpack/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nilayjain/mlpack/downloads","issues_url":"https://api.github.com/repos/nilayjain/mlpack/issues{/number}","pulls_url":"https://api.github.com/repos/nilayjain/mlpack/pulls{/number}","milestones_url":"https://api.github.com/repos/nilayjain/mlpack/milestones{/number}","notifications_url":"https://api.github.com/repos/nilayjain/mlpack/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nilayjain/mlpack/labels{/name}","releases_url":"https://api.github.com/repos/nilayjain/mlpack/releases{/id}","deployments_url":"https://api.github.com/repos/nilayjain/mlpack/deployments","created_at":"2016-06-05T12:16:26Z","updated_at":"2016-06-05T12:16:30Z","pushed_at":"2016-06-07T20:04:01Z","git_url":"git://github.com/nilayjain/mlpack.git","ssh_url":"git@github.com:nilayjain/mlpack.git","clone_url":"https://github.com/nilayjain/mlpack.git","svn_url":"https://github.com/nilayjain/mlpack","homepage":null,"size":145476,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mlpack:master","ref":"master","sha":"44883afb19a2f2dd0e1fe29d96c873bf97335521","user":{"login":"mlpack","id":10216045,"avatar_url":"https://avatars.githubusercontent.com/u/10216045?v=3","gravatar_id":"","url":"https://api.github.com/users/mlpack","html_url":"https://github.com/mlpack","followers_url":"https://api.github.com/users/mlpack/followers","following_url":"https://api.github.com/users/mlpack/following{/other_user}","gists_url":"https://api.github.com/users/mlpack/gists{/gist_id}","starred_url":"https://api.github.com/users/mlpack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mlpack/subscriptions","organizations_url":"https://api.github.com/users/mlpack/orgs","repos_url":"https://api.github.com/users/mlpack/repos","events_url":"https://api.github.com/users/mlpack/events{/privacy}","received_events_url":"https://api.github.com/users/mlpack/received_events","type":"Organization","site_admin":false},"repo":{"id":28149409,"name":"mlpack","full_name":"mlpack/mlpack","owner":{"login":"mlpack","id":10216045,"avatar_url":"https://avatars.githubusercontent.com/u/10216045?v=3","gravatar_id":"","url":"https://api.github.com/users/mlpack","html_url":"https://github.com/mlpack","followers_url":"https://api.github.com/users/mlpack/followers","following_url":"https://api.github.com/users/mlpack/following{/other_user}","gists_url":"https://api.github.com/users/mlpack/gists{/gist_id}","starred_url":"https://api.github.com/users/mlpack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mlpack/subscriptions","organizations_url":"https://api.github.com/users/mlpack/orgs","repos_url":"https://api.github.com/users/mlpack/repos","events_url":"https://api.github.com/users/mlpack/events{/privacy}","received_events_url":"https://api.github.com/users/mlpack/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mlpack/mlpack","description":"mlpack: a scalable C++ machine learning library","fork":false,"url":"https://api.github.com/repos/mlpack/mlpack","forks_url":"https://api.github.com/repos/mlpack/mlpack/forks","keys_url":"https://api.github.com/repos/mlpack/mlpack/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mlpack/mlpack/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mlpack/mlpack/teams","hooks_url":"https://api.github.com/repos/mlpack/mlpack/hooks","issue_events_url":"https://api.github.com/repos/mlpack/mlpack/issues/events{/number}","events_url":"https://api.github.com/repos/mlpack/mlpack/events","assignees_url":"https://api.github.com/repos/mlpack/mlpack/assignees{/user}","branches_url":"https://api.github.com/repos/mlpack/mlpack/branches{/branch}","tags_url":"https://api.github.com/repos/mlpack/mlpack/tags","blobs_url":"https://api.github.com/repos/mlpack/mlpack/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mlpack/mlpack/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mlpack/mlpack/git/refs{/sha}","trees_url":"https://api.github.com/repos/mlpack/mlpack/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mlpack/mlpack/statuses/{sha}","languages_url":"https://api.github.com/repos/mlpack/mlpack/languages","stargazers_url":"https://api.github.com/repos/mlpack/mlpack/stargazers","contributors_url":"https://api.github.com/repos/mlpack/mlpack/contributors","subscribers_url":"https://api.github.com/repos/mlpack/mlpack/subscribers","subscription_url":"https://api.github.com/repos/mlpack/mlpack/subscription","commits_url":"https://api.github.com/repos/mlpack/mlpack/commits{/sha}","git_commits_url":"https://api.github.com/repos/mlpack/mlpack/git/commits{/sha}","comments_url":"https://api.github.com/repos/mlpack/mlpack/comments{/number}","issue_comment_url":"https://api.github.com/repos/mlpack/mlpack/issues/comments{/number}","contents_url":"https://api.github.com/repos/mlpack/mlpack/contents/{+path}","compare_url":"https://api.github.com/repos/mlpack/mlpack/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mlpack/mlpack/merges","archive_url":"https://api.github.com/repos/mlpack/mlpack/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mlpack/mlpack/downloads","issues_url":"https://api.github.com/repos/mlpack/mlpack/issues{/number}","pulls_url":"https://api.github.com/repos/mlpack/mlpack/pulls{/number}","milestones_url":"https://api.github.com/repos/mlpack/mlpack/milestones{/number}","notifications_url":"https://api.github.com/repos/mlpack/mlpack/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mlpack/mlpack/labels{/name}","releases_url":"https://api.github.com/repos/mlpack/mlpack/releases{/id}","deployments_url":"https://api.github.com/repos/mlpack/mlpack/deployments","created_at":"2014-12-17T18:16:59Z","updated_at":"2016-06-09T15:10:19Z","pushed_at":"2016-06-09T13:57:20Z","git_url":"git://github.com/mlpack/mlpack.git","ssh_url":"git@github.com:mlpack/mlpack.git","clone_url":"https://github.com/mlpack/mlpack.git","svn_url":"https://github.com/mlpack/mlpack","homepage":null,"size":165222,"stargazers_count":864,"watchers_count":864,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":343,"mirror_url":null,"open_issues_count":72,"forks":343,"open_issues":72,"watchers":864,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mlpack/mlpack/pulls/683"},"html":{"href":"https://github.com/mlpack/mlpack/pull/683"},"issue":{"href":"https://api.github.com/repos/mlpack/mlpack/issues/683"},"comments":{"href":"https://api.github.com/repos/mlpack/mlpack/issues/683/comments"},"review_comments":{"href":"https://api.github.com/repos/mlpack/mlpack/pulls/683/comments"},"review_comment":{"href":"https://api.github.com/repos/mlpack/mlpack/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mlpack/mlpack/pulls/683/commits"},"statuses":{"href":"https://api.github.com/repos/mlpack/mlpack/statuses/05fcf0bc43f6ee18cbccca8c5558197b2c50f511"}}}}
{"actor":{"display_login":"stereomatchingkiss"}}