{"action":"created","comment":{"url":"https://api.github.com/repos/libfann/fann/pulls/comments/190992062","pull_request_review_id":123491873,"id":190992062,"diff_hunk":"@@ -1186,8 +1186,10 @@ FANN_EXTERNAL void FANN_API fann_descale_train( struct fann *ann, struct fann_tr\n \t\t\t\t\t- ann->scale_mean_##where[ cur_neuron ] \t\t\t\t\t\t\t\t\t\t\t\\\n \t\t\t\t); \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\\\n \tfor( cur_neuron = 0; cur_neuron < ann->num_##where##put; cur_neuron++ )\t\t\t\t\t\t\t\t\\\n+\t\t/* If all inputs are the same, set deviation to 1 instead of 0 to avoid division-by-zero */     \\\n \t\tann->scale_deviation_##where[ cur_neuron ] =\t\t\t\t\t\t\t\t\t\t\t\t\t\\\n-\t\t\tsqrtf( ann->scale_deviation_##where[ cur_neuron ] / (float)data->num_data ); \t\t\t\\\n+\t\t\tann->scale_deviation_##where[ cur_neuron ] == 0.0f ? 1.0 :                                  \\\n+\t\t\t\tsqrtf( ann->scale_deviation_##where[ cur_neuron ] / (float)data->num_data ); \t\t\t\\\n \t/* Calculate factor: (new_max-new_min)/(old_max(1)-old_min(-1)) */\t\t\t\t\t\t\t\t\t\\\n \t/* Looks like we dont need whole array of factors? */\t\t\t\t\t\t\t\t\t\t\t\t\\","path":"src/fann_train_data.c","position":10,"original_position":10,"commit_id":"4741a726fcdecc3bfe23c574c531e1e75548b9c5","original_commit_id":"4741a726fcdecc3bfe23c574c531e1e75548b9c5","user":{"login":"troiganto","id":5731814,"avatar_url":"https://avatars1.githubusercontent.com/u/5731814?v=4","gravatar_id":"","url":"https://api.github.com/users/troiganto","html_url":"https://github.com/troiganto","followers_url":"https://api.github.com/users/troiganto/followers","following_url":"https://api.github.com/users/troiganto/following{/other_user}","gists_url":"https://api.github.com/users/troiganto/gists{/gist_id}","starred_url":"https://api.github.com/users/troiganto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/troiganto/subscriptions","organizations_url":"https://api.github.com/users/troiganto/orgs","repos_url":"https://api.github.com/users/troiganto/repos","events_url":"https://api.github.com/users/troiganto/events{/privacy}","received_events_url":"https://api.github.com/users/troiganto/received_events","type":"User","site_admin":false},"body":"Not sure if it's a good idea, but to make it more obvious what's going on, we could also put the check into a separate statement. Something like this:\r\n\r\n```c\r\nfor( cur_neuron = 0; cur_neuron < ann->num_##where##put; cur_neuron++ ) {\r\n  ann->scale_deviation_##where[ cur_neuron ] =\r\n    sqrtf( ann->scale_deviation_##where[ cur_neuron ] / (float)data->num_data );\r\n  if( ann->scale_deviation_##where[ cur_neuron ] == 0.0f ) {\r\n    /* explanatory comment here */\r\n    ann->scale_deviation_##where[ cur_neuron ] = 1.0f;\r\n  }\r\n}\r\n```\r\nBut using the ternary operator as in the original commit seemed more ~efficient~ to me.","created_at":"2018-05-25T19:38:49Z","updated_at":"2018-05-25T19:38:50Z","html_url":"https://github.com/libfann/fann/pull/101#discussion_r190992062","pull_request_url":"https://api.github.com/repos/libfann/fann/pulls/101","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/libfann/fann/pulls/comments/190992062"},"html":{"href":"https://github.com/libfann/fann/pull/101#discussion_r190992062"},"pull_request":{"href":"https://api.github.com/repos/libfann/fann/pulls/101"}},"in_reply_to_id":190869819},"pull_request":{"url":"https://api.github.com/repos/libfann/fann/pulls/101","id":190439214,"html_url":"https://github.com/libfann/fann/pull/101","diff_url":"https://github.com/libfann/fann/pull/101.diff","patch_url":"https://github.com/libfann/fann/pull/101.patch","issue_url":"https://api.github.com/repos/libfann/fann/issues/101","number":101,"state":"open","locked":false,"title":"Catch zero standard deviation in data scaling logic.","user":{"login":"troiganto","id":5731814,"avatar_url":"https://avatars1.githubusercontent.com/u/5731814?v=4","gravatar_id":"","url":"https://api.github.com/users/troiganto","html_url":"https://github.com/troiganto","followers_url":"https://api.github.com/users/troiganto/followers","following_url":"https://api.github.com/users/troiganto/following{/other_user}","gists_url":"https://api.github.com/users/troiganto/gists{/gist_id}","starred_url":"https://api.github.com/users/troiganto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/troiganto/subscriptions","organizations_url":"https://api.github.com/users/troiganto/orgs","repos_url":"https://api.github.com/users/troiganto/repos","events_url":"https://api.github.com/users/troiganto/events{/privacy}","received_events_url":"https://api.github.com/users/troiganto/received_events","type":"User","site_admin":false},"body":"Closes #99.\r\n\r\nContrary to the suggestion given by the @charlie5, I decided to put the check to where the standard deviation is calculated, not where the scaling happens. This way, we handle both scaling and descaling in one go.\r\n\r\nI set the standard deviation from zero to one so that there is still *some* sort of scaling happening. I guess another option would be to just return some form of error on zero.","created_at":"2018-05-24T22:39:19Z","updated_at":"2018-05-25T19:38:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7229c8cd266b7327bd378f0950564055dfc6857b","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/libfann/fann/pulls/101/commits","review_comments_url":"https://api.github.com/repos/libfann/fann/pulls/101/comments","review_comment_url":"https://api.github.com/repos/libfann/fann/pulls/comments{/number}","comments_url":"https://api.github.com/repos/libfann/fann/issues/101/comments","statuses_url":"https://api.github.com/repos/libfann/fann/statuses/4741a726fcdecc3bfe23c574c531e1e75548b9c5","head":{"label":"troiganto:master","ref":"master","sha":"4741a726fcdecc3bfe23c574c531e1e75548b9c5","user":{"login":"troiganto","id":5731814,"avatar_url":"https://avatars1.githubusercontent.com/u/5731814?v=4","gravatar_id":"","url":"https://api.github.com/users/troiganto","html_url":"https://github.com/troiganto","followers_url":"https://api.github.com/users/troiganto/followers","following_url":"https://api.github.com/users/troiganto/following{/other_user}","gists_url":"https://api.github.com/users/troiganto/gists{/gist_id}","starred_url":"https://api.github.com/users/troiganto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/troiganto/subscriptions","organizations_url":"https://api.github.com/users/troiganto/orgs","repos_url":"https://api.github.com/users/troiganto/repos","events_url":"https://api.github.com/users/troiganto/events{/privacy}","received_events_url":"https://api.github.com/users/troiganto/received_events","type":"User","site_admin":false},"repo":{"id":134771969,"name":"fann","full_name":"troiganto/fann","owner":{"login":"troiganto","id":5731814,"avatar_url":"https://avatars1.githubusercontent.com/u/5731814?v=4","gravatar_id":"","url":"https://api.github.com/users/troiganto","html_url":"https://github.com/troiganto","followers_url":"https://api.github.com/users/troiganto/followers","following_url":"https://api.github.com/users/troiganto/following{/other_user}","gists_url":"https://api.github.com/users/troiganto/gists{/gist_id}","starred_url":"https://api.github.com/users/troiganto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/troiganto/subscriptions","organizations_url":"https://api.github.com/users/troiganto/orgs","repos_url":"https://api.github.com/users/troiganto/repos","events_url":"https://api.github.com/users/troiganto/events{/privacy}","received_events_url":"https://api.github.com/users/troiganto/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/troiganto/fann","description":"Official github repository for Fast Artificial Neural Network Library (FANN)","fork":true,"url":"https://api.github.com/repos/troiganto/fann","forks_url":"https://api.github.com/repos/troiganto/fann/forks","keys_url":"https://api.github.com/repos/troiganto/fann/keys{/key_id}","collaborators_url":"https://api.github.com/repos/troiganto/fann/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/troiganto/fann/teams","hooks_url":"https://api.github.com/repos/troiganto/fann/hooks","issue_events_url":"https://api.github.com/repos/troiganto/fann/issues/events{/number}","events_url":"https://api.github.com/repos/troiganto/fann/events","assignees_url":"https://api.github.com/repos/troiganto/fann/assignees{/user}","branches_url":"https://api.github.com/repos/troiganto/fann/branches{/branch}","tags_url":"https://api.github.com/repos/troiganto/fann/tags","blobs_url":"https://api.github.com/repos/troiganto/fann/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/troiganto/fann/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/troiganto/fann/git/refs{/sha}","trees_url":"https://api.github.com/repos/troiganto/fann/git/trees{/sha}","statuses_url":"https://api.github.com/repos/troiganto/fann/statuses/{sha}","languages_url":"https://api.github.com/repos/troiganto/fann/languages","stargazers_url":"https://api.github.com/repos/troiganto/fann/stargazers","contributors_url":"https://api.github.com/repos/troiganto/fann/contributors","subscribers_url":"https://api.github.com/repos/troiganto/fann/subscribers","subscription_url":"https://api.github.com/repos/troiganto/fann/subscription","commits_url":"https://api.github.com/repos/troiganto/fann/commits{/sha}","git_commits_url":"https://api.github.com/repos/troiganto/fann/git/commits{/sha}","comments_url":"https://api.github.com/repos/troiganto/fann/comments{/number}","issue_comment_url":"https://api.github.com/repos/troiganto/fann/issues/comments{/number}","contents_url":"https://api.github.com/repos/troiganto/fann/contents/{+path}","compare_url":"https://api.github.com/repos/troiganto/fann/compare/{base}...{head}","merges_url":"https://api.github.com/repos/troiganto/fann/merges","archive_url":"https://api.github.com/repos/troiganto/fann/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/troiganto/fann/downloads","issues_url":"https://api.github.com/repos/troiganto/fann/issues{/number}","pulls_url":"https://api.github.com/repos/troiganto/fann/pulls{/number}","milestones_url":"https://api.github.com/repos/troiganto/fann/milestones{/number}","notifications_url":"https://api.github.com/repos/troiganto/fann/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/troiganto/fann/labels{/name}","releases_url":"https://api.github.com/repos/troiganto/fann/releases{/id}","deployments_url":"https://api.github.com/repos/troiganto/fann/deployments","created_at":"2018-05-24T21:45:26Z","updated_at":"2018-05-24T22:22:47Z","pushed_at":"2018-05-24T22:22:45Z","git_url":"git://github.com/troiganto/fann.git","ssh_url":"git@github.com:troiganto/fann.git","clone_url":"https://github.com/troiganto/fann.git","svn_url":"https://github.com/troiganto/fann","homepage":null,"size":9699,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"lgpl-2.1","name":"GNU Lesser General Public License v2.1","spdx_id":"LGPL-2.1","url":"https://api.github.com/licenses/lgpl-2.1"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"libfann:master","ref":"master","sha":"b362b4bf8440f16ecf408ed6ab2a788bdea5c65f","user":{"login":"libfann","id":6076229,"avatar_url":"https://avatars1.githubusercontent.com/u/6076229?v=4","gravatar_id":"","url":"https://api.github.com/users/libfann","html_url":"https://github.com/libfann","followers_url":"https://api.github.com/users/libfann/followers","following_url":"https://api.github.com/users/libfann/following{/other_user}","gists_url":"https://api.github.com/users/libfann/gists{/gist_id}","starred_url":"https://api.github.com/users/libfann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/libfann/subscriptions","organizations_url":"https://api.github.com/users/libfann/orgs","repos_url":"https://api.github.com/users/libfann/repos","events_url":"https://api.github.com/users/libfann/events{/privacy}","received_events_url":"https://api.github.com/users/libfann/received_events","type":"Organization","site_admin":false},"repo":{"id":14833195,"name":"fann","full_name":"libfann/fann","owner":{"login":"libfann","id":6076229,"avatar_url":"https://avatars1.githubusercontent.com/u/6076229?v=4","gravatar_id":"","url":"https://api.github.com/users/libfann","html_url":"https://github.com/libfann","followers_url":"https://api.github.com/users/libfann/followers","following_url":"https://api.github.com/users/libfann/following{/other_user}","gists_url":"https://api.github.com/users/libfann/gists{/gist_id}","starred_url":"https://api.github.com/users/libfann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/libfann/subscriptions","organizations_url":"https://api.github.com/users/libfann/orgs","repos_url":"https://api.github.com/users/libfann/repos","events_url":"https://api.github.com/users/libfann/events{/privacy}","received_events_url":"https://api.github.com/users/libfann/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/libfann/fann","description":"Official github repository for Fast Artificial Neural Network Library (FANN)","fork":false,"url":"https://api.github.com/repos/libfann/fann","forks_url":"https://api.github.com/repos/libfann/fann/forks","keys_url":"https://api.github.com/repos/libfann/fann/keys{/key_id}","collaborators_url":"https://api.github.com/repos/libfann/fann/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/libfann/fann/teams","hooks_url":"https://api.github.com/repos/libfann/fann/hooks","issue_events_url":"https://api.github.com/repos/libfann/fann/issues/events{/number}","events_url":"https://api.github.com/repos/libfann/fann/events","assignees_url":"https://api.github.com/repos/libfann/fann/assignees{/user}","branches_url":"https://api.github.com/repos/libfann/fann/branches{/branch}","tags_url":"https://api.github.com/repos/libfann/fann/tags","blobs_url":"https://api.github.com/repos/libfann/fann/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/libfann/fann/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/libfann/fann/git/refs{/sha}","trees_url":"https://api.github.com/repos/libfann/fann/git/trees{/sha}","statuses_url":"https://api.github.com/repos/libfann/fann/statuses/{sha}","languages_url":"https://api.github.com/repos/libfann/fann/languages","stargazers_url":"https://api.github.com/repos/libfann/fann/stargazers","contributors_url":"https://api.github.com/repos/libfann/fann/contributors","subscribers_url":"https://api.github.com/repos/libfann/fann/subscribers","subscription_url":"https://api.github.com/repos/libfann/fann/subscription","commits_url":"https://api.github.com/repos/libfann/fann/commits{/sha}","git_commits_url":"https://api.github.com/repos/libfann/fann/git/commits{/sha}","comments_url":"https://api.github.com/repos/libfann/fann/comments{/number}","issue_comment_url":"https://api.github.com/repos/libfann/fann/issues/comments{/number}","contents_url":"https://api.github.com/repos/libfann/fann/contents/{+path}","compare_url":"https://api.github.com/repos/libfann/fann/compare/{base}...{head}","merges_url":"https://api.github.com/repos/libfann/fann/merges","archive_url":"https://api.github.com/repos/libfann/fann/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/libfann/fann/downloads","issues_url":"https://api.github.com/repos/libfann/fann/issues{/number}","pulls_url":"https://api.github.com/repos/libfann/fann/pulls{/number}","milestones_url":"https://api.github.com/repos/libfann/fann/milestones{/number}","notifications_url":"https://api.github.com/repos/libfann/fann/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/libfann/fann/labels{/name}","releases_url":"https://api.github.com/repos/libfann/fann/releases{/id}","deployments_url":"https://api.github.com/repos/libfann/fann/deployments","created_at":"2013-12-01T03:48:49Z","updated_at":"2018-05-25T09:17:45Z","pushed_at":"2018-05-24T22:39:20Z","git_url":"git://github.com/libfann/fann.git","ssh_url":"git@github.com:libfann/fann.git","clone_url":"https://github.com/libfann/fann.git","svn_url":"https://github.com/libfann/fann","homepage":null,"size":9700,"stargazers_count":952,"watchers_count":952,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":276,"mirror_url":null,"archived":false,"open_issues_count":24,"license":{"key":"lgpl-2.1","name":"GNU Lesser General Public License v2.1","spdx_id":"LGPL-2.1","url":"https://api.github.com/licenses/lgpl-2.1"},"forks":276,"open_issues":24,"watchers":952,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/libfann/fann/pulls/101"},"html":{"href":"https://github.com/libfann/fann/pull/101"},"issue":{"href":"https://api.github.com/repos/libfann/fann/issues/101"},"comments":{"href":"https://api.github.com/repos/libfann/fann/issues/101/comments"},"review_comments":{"href":"https://api.github.com/repos/libfann/fann/pulls/101/comments"},"review_comment":{"href":"https://api.github.com/repos/libfann/fann/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/libfann/fann/pulls/101/commits"},"statuses":{"href":"https://api.github.com/repos/libfann/fann/statuses/4741a726fcdecc3bfe23c574c531e1e75548b9c5"}},"author_association":"NONE"}}
{"actor":{"display_login":"troiganto"}}