{"action":"created","comment":{"url":"https://api.github.com/repos/mlpack/mlpack/pulls/comments/73803338","id":73803338,"diff_hunk":"@@ -0,0 +1,88 @@\n+/**\n+ * @file utils.hpp\n+ * @author Bang Liu\n+ *\n+ * Definition of utils.\n+ */\n+#ifndef UTILS_HPP\n+#define UTILS_HPP\n+\n+#include <cstddef>\n+#include <cmath>\n+#include <ctime>\n+\n+#include <boost/random.hpp>\n+\n+typedef boost::mt19937 RNGType;  // Choose random number generator.\n+\n+namespace mlpack {\n+namespace ne {\n+\n+/**\n+ * Definitions of different activate functions.\n+ */\n+\n+inline double sigmoid(double x) {  // TODO: make it faster. More parameters?\n+  return 1.0 / (1.0 + exp(-x));\n+}\n+\n+inline double relu(double x) {\n+  return (x > 0)? x:0;\n+}\n+\n+/**\n+ * Definitions of random number generation functions.\n+ */\n+\n+// Random number generator.\n+RNGType rng;\n+\n+// Set seed for random number generator\n+void Seed(int seedVal) {\n+  rng.seed(seedVal);\n+}\n+\n+// Set seed by time for random number generator\n+void TimeSeed() {\n+  rng.seed(time(0));\n+}\n+\n+// Returns randomly either 1 or -1\n+int RandPosNeg() {\n+  boost::random::uniform_int_distribution<> dist(0, 1);\n+  return dist(rng);\n+}\n+\n+// Returns a random integer between [x, y]\n+// in case of ( 0 .. 1 ) returns 0\n+int RandInt(int x, int y) {\n+\tboost::random::uniform_int_distribution<> dist(x, y);\n+    return dist(rng);\n+}\n+\n+// Return a random float between [0, 1]\n+double RandFloat() {\n+  boost::random::uniform_01<> dist;\n+  return dist(rng);\n+  \n+}\n+\n+// Return a random float between [x, y]\n+double RandFloat(double x, double y) {\n+  boost::random::uniform_real_distribution<> dist(x, y);\n+  return dist(rng);\n+}\n+\n+/**\n+ * Definitions of other functions.\n+ */\n+\n+// Return the sign of a number.\n+template <typename T> int sgn(T val) {","path":"src/mlpack/methods/ne/utils.hpp","position":81,"original_position":81,"commit_id":"10b99ab5c6e8d2836d231fa60a898cc03f7d9192","original_commit_id":"10b99ab5c6e8d2836d231fa60a898cc03f7d9192","user":{"login":"zoq","id":4209744,"avatar_url":"https://avatars.githubusercontent.com/u/4209744?v=3","gravatar_id":"","url":"https://api.github.com/users/zoq","html_url":"https://github.com/zoq","followers_url":"https://api.github.com/users/zoq/followers","following_url":"https://api.github.com/users/zoq/following{/other_user}","gists_url":"https://api.github.com/users/zoq/gists{/gist_id}","starred_url":"https://api.github.com/users/zoq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zoq/subscriptions","organizations_url":"https://api.github.com/users/zoq/orgs","repos_url":"https://api.github.com/users/zoq/repos","events_url":"https://api.github.com/users/zoq/events{/privacy}","received_events_url":"https://api.github.com/users/zoq/received_events","type":"User","site_admin":false},"body":"What about using ``arma::sign(val)`` take a look at: http://arma.sourceforge.net/docs.html#misc_fns for more informations.","created_at":"2016-08-07T14:58:08Z","updated_at":"2016-08-07T14:58:08Z","html_url":"https://github.com/mlpack/mlpack/pull/753#discussion_r73803338","pull_request_url":"https://api.github.com/repos/mlpack/mlpack/pulls/753","_links":{"self":{"href":"https://api.github.com/repos/mlpack/mlpack/pulls/comments/73803338"},"html":{"href":"https://github.com/mlpack/mlpack/pull/753#discussion_r73803338"},"pull_request":{"href":"https://api.github.com/repos/mlpack/mlpack/pulls/753"}}},"pull_request":{"url":"https://api.github.com/repos/mlpack/mlpack/pulls/753","id":80299086,"html_url":"https://github.com/mlpack/mlpack/pull/753","diff_url":"https://github.com/mlpack/mlpack/pull/753.diff","patch_url":"https://github.com/mlpack/mlpack/pull/753.patch","issue_url":"https://api.github.com/repos/mlpack/mlpack/issues/753","number":753,"state":"open","locked":false,"title":"CNE algorithm","user":{"login":"BangLiu","id":4156705,"avatar_url":"https://avatars.githubusercontent.com/u/4156705?v=3","gravatar_id":"","url":"https://api.github.com/users/BangLiu","html_url":"https://github.com/BangLiu","followers_url":"https://api.github.com/users/BangLiu/followers","following_url":"https://api.github.com/users/BangLiu/following{/other_user}","gists_url":"https://api.github.com/users/BangLiu/gists{/gist_id}","starred_url":"https://api.github.com/users/BangLiu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BangLiu/subscriptions","organizations_url":"https://api.github.com/users/BangLiu/orgs","repos_url":"https://api.github.com/users/BangLiu/repos","events_url":"https://api.github.com/users/BangLiu/events{/privacy}","received_events_url":"https://api.github.com/users/BangLiu/received_events","type":"User","site_admin":false},"body":"Implemented CNE algorithm, and XOR test case.","created_at":"2016-08-05T20:02:15Z","updated_at":"2016-08-07T14:58:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"adf786c4d2cd05bab555cf3c13bb1383172bf351","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/mlpack/mlpack/pulls/753/commits","review_comments_url":"https://api.github.com/repos/mlpack/mlpack/pulls/753/comments","review_comment_url":"https://api.github.com/repos/mlpack/mlpack/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mlpack/mlpack/issues/753/comments","statuses_url":"https://api.github.com/repos/mlpack/mlpack/statuses/10b99ab5c6e8d2836d231fa60a898cc03f7d9192","head":{"label":"BangLiu:cne","ref":"cne","sha":"10b99ab5c6e8d2836d231fa60a898cc03f7d9192","user":{"login":"BangLiu","id":4156705,"avatar_url":"https://avatars.githubusercontent.com/u/4156705?v=3","gravatar_id":"","url":"https://api.github.com/users/BangLiu","html_url":"https://github.com/BangLiu","followers_url":"https://api.github.com/users/BangLiu/followers","following_url":"https://api.github.com/users/BangLiu/following{/other_user}","gists_url":"https://api.github.com/users/BangLiu/gists{/gist_id}","starred_url":"https://api.github.com/users/BangLiu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BangLiu/subscriptions","organizations_url":"https://api.github.com/users/BangLiu/orgs","repos_url":"https://api.github.com/users/BangLiu/repos","events_url":"https://api.github.com/users/BangLiu/events{/privacy}","received_events_url":"https://api.github.com/users/BangLiu/received_events","type":"User","site_admin":false},"repo":{"id":58986089,"name":"mlpack","full_name":"BangLiu/mlpack","owner":{"login":"BangLiu","id":4156705,"avatar_url":"https://avatars.githubusercontent.com/u/4156705?v=3","gravatar_id":"","url":"https://api.github.com/users/BangLiu","html_url":"https://github.com/BangLiu","followers_url":"https://api.github.com/users/BangLiu/followers","following_url":"https://api.github.com/users/BangLiu/following{/other_user}","gists_url":"https://api.github.com/users/BangLiu/gists{/gist_id}","starred_url":"https://api.github.com/users/BangLiu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BangLiu/subscriptions","organizations_url":"https://api.github.com/users/BangLiu/orgs","repos_url":"https://api.github.com/users/BangLiu/repos","events_url":"https://api.github.com/users/BangLiu/events{/privacy}","received_events_url":"https://api.github.com/users/BangLiu/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/BangLiu/mlpack","description":"mlpack: a scalable C++ machine learning library","fork":true,"url":"https://api.github.com/repos/BangLiu/mlpack","forks_url":"https://api.github.com/repos/BangLiu/mlpack/forks","keys_url":"https://api.github.com/repos/BangLiu/mlpack/keys{/key_id}","collaborators_url":"https://api.github.com/repos/BangLiu/mlpack/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/BangLiu/mlpack/teams","hooks_url":"https://api.github.com/repos/BangLiu/mlpack/hooks","issue_events_url":"https://api.github.com/repos/BangLiu/mlpack/issues/events{/number}","events_url":"https://api.github.com/repos/BangLiu/mlpack/events","assignees_url":"https://api.github.com/repos/BangLiu/mlpack/assignees{/user}","branches_url":"https://api.github.com/repos/BangLiu/mlpack/branches{/branch}","tags_url":"https://api.github.com/repos/BangLiu/mlpack/tags","blobs_url":"https://api.github.com/repos/BangLiu/mlpack/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/BangLiu/mlpack/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/BangLiu/mlpack/git/refs{/sha}","trees_url":"https://api.github.com/repos/BangLiu/mlpack/git/trees{/sha}","statuses_url":"https://api.github.com/repos/BangLiu/mlpack/statuses/{sha}","languages_url":"https://api.github.com/repos/BangLiu/mlpack/languages","stargazers_url":"https://api.github.com/repos/BangLiu/mlpack/stargazers","contributors_url":"https://api.github.com/repos/BangLiu/mlpack/contributors","subscribers_url":"https://api.github.com/repos/BangLiu/mlpack/subscribers","subscription_url":"https://api.github.com/repos/BangLiu/mlpack/subscription","commits_url":"https://api.github.com/repos/BangLiu/mlpack/commits{/sha}","git_commits_url":"https://api.github.com/repos/BangLiu/mlpack/git/commits{/sha}","comments_url":"https://api.github.com/repos/BangLiu/mlpack/comments{/number}","issue_comment_url":"https://api.github.com/repos/BangLiu/mlpack/issues/comments{/number}","contents_url":"https://api.github.com/repos/BangLiu/mlpack/contents/{+path}","compare_url":"https://api.github.com/repos/BangLiu/mlpack/compare/{base}...{head}","merges_url":"https://api.github.com/repos/BangLiu/mlpack/merges","archive_url":"https://api.github.com/repos/BangLiu/mlpack/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/BangLiu/mlpack/downloads","issues_url":"https://api.github.com/repos/BangLiu/mlpack/issues{/number}","pulls_url":"https://api.github.com/repos/BangLiu/mlpack/pulls{/number}","milestones_url":"https://api.github.com/repos/BangLiu/mlpack/milestones{/number}","notifications_url":"https://api.github.com/repos/BangLiu/mlpack/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/BangLiu/mlpack/labels{/name}","releases_url":"https://api.github.com/repos/BangLiu/mlpack/releases{/id}","deployments_url":"https://api.github.com/repos/BangLiu/mlpack/deployments","created_at":"2016-05-17T03:04:31Z","updated_at":"2016-05-17T03:04:35Z","pushed_at":"2016-08-06T16:20:09Z","git_url":"git://github.com/BangLiu/mlpack.git","ssh_url":"git@github.com:BangLiu/mlpack.git","clone_url":"https://github.com/BangLiu/mlpack.git","svn_url":"https://github.com/BangLiu/mlpack","homepage":null,"size":147150,"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":"53a028176c72c8f695a51881e993a84a225d738e","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-08-06T09:18:05Z","pushed_at":"2016-08-07T11:16:00Z","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":168340,"stargazers_count":1085,"watchers_count":1085,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":378,"mirror_url":null,"open_issues_count":81,"forks":378,"open_issues":81,"watchers":1085,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mlpack/mlpack/pulls/753"},"html":{"href":"https://github.com/mlpack/mlpack/pull/753"},"issue":{"href":"https://api.github.com/repos/mlpack/mlpack/issues/753"},"comments":{"href":"https://api.github.com/repos/mlpack/mlpack/issues/753/comments"},"review_comments":{"href":"https://api.github.com/repos/mlpack/mlpack/pulls/753/comments"},"review_comment":{"href":"https://api.github.com/repos/mlpack/mlpack/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mlpack/mlpack/pulls/753/commits"},"statuses":{"href":"https://api.github.com/repos/mlpack/mlpack/statuses/10b99ab5c6e8d2836d231fa60a898cc03f7d9192"}}}}
{"actor":{"display_login":"zoq"}}