{"action":"created","issue":{"url":"https://api.github.com/repos/arrayfire/arrayfire/issues/492","labels_url":"https://api.github.com/repos/arrayfire/arrayfire/issues/492/labels{/name}","comments_url":"https://api.github.com/repos/arrayfire/arrayfire/issues/492/comments","events_url":"https://api.github.com/repos/arrayfire/arrayfire/issues/492/events","html_url":"https://github.com/arrayfire/arrayfire/issues/492","id":60772468,"number":492,"title":"How best to create onehot vector?","user":{"login":"jeremysalwen","id":450638,"avatar_url":"https://avatars.githubusercontent.com/u/450638?v=3","gravatar_id":"","url":"https://api.github.com/users/jeremysalwen","html_url":"https://github.com/jeremysalwen","followers_url":"https://api.github.com/users/jeremysalwen/followers","following_url":"https://api.github.com/users/jeremysalwen/following{/other_user}","gists_url":"https://api.github.com/users/jeremysalwen/gists{/gist_id}","starred_url":"https://api.github.com/users/jeremysalwen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeremysalwen/subscriptions","organizations_url":"https://api.github.com/users/jeremysalwen/orgs","repos_url":"https://api.github.com/users/jeremysalwen/repos","events_url":"https://api.github.com/users/jeremysalwen/events{/privacy}","received_events_url":"https://api.github.com/users/jeremysalwen/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/arrayfire/arrayfire/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-03-12T05:17:07Z","updated_at":"2015-03-12T14:04:09Z","closed_at":null,"body":"What is the best way to create a onehot representation of an integer using Arrayfire?\r\n\r\nfor example, I would like to turn \r\n```\r\n1\r\n4\r\n2\r\n5\r\n```\r\ninto a matrix like\r\n\r\n```\r\n010000\r\n000010\r\n001000\r\n000001\r\n```\r\nWhere I would give the parameter of the width of the onehot representation (in this case 6)."},"comment":{"url":"https://api.github.com/repos/arrayfire/arrayfire/issues/comments/78484955","html_url":"https://github.com/arrayfire/arrayfire/issues/492#issuecomment-78484955","issue_url":"https://api.github.com/repos/arrayfire/arrayfire/issues/492","id":78484955,"user":{"login":"pavanky","id":364829,"avatar_url":"https://avatars.githubusercontent.com/u/364829?v=3","gravatar_id":"","url":"https://api.github.com/users/pavanky","html_url":"https://github.com/pavanky","followers_url":"https://api.github.com/users/pavanky/followers","following_url":"https://api.github.com/users/pavanky/following{/other_user}","gists_url":"https://api.github.com/users/pavanky/gists{/gist_id}","starred_url":"https://api.github.com/users/pavanky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pavanky/subscriptions","organizations_url":"https://api.github.com/users/pavanky/orgs","repos_url":"https://api.github.com/users/pavanky/repos","events_url":"https://api.github.com/users/pavanky/events{/privacy}","received_events_url":"https://api.github.com/users/pavanky/received_events","type":"User","site_admin":false},"created_at":"2015-03-12T14:04:09Z","updated_at":"2015-03-12T14:04:09Z","body":"Ah I see you want to convert the target classes into one hot representation! We do that for our examples in [mnist_common.h](https://github.com/arrayfire/arrayfire/blob/devel/examples/machine_learning/mnist_common.h#L73). Look at the code under \"expand\". This is not the most efficient way to do things.\r\n\r\nWe will eventually be adding a function like the following:\r\n\r\n```\r\narray onehot = assign(zeros_array, indices, ones_array);\r\n```"}}