{"action":"created","issue":{"url":"https://api.github.com/repos/fchollet/keras/issues/3695","repository_url":"https://api.github.com/repos/fchollet/keras","labels_url":"https://api.github.com/repos/fchollet/keras/issues/3695/labels{/name}","comments_url":"https://api.github.com/repos/fchollet/keras/issues/3695/comments","events_url":"https://api.github.com/repos/fchollet/keras/issues/3695/events","html_url":"https://github.com/fchollet/keras/pull/3695","id":175135884,"number":3695,"title":"Minimal SparseTensor support for TensorFlow","user":{"login":"kuza55","id":387986,"avatar_url":"https://avatars.githubusercontent.com/u/387986?v=3","gravatar_id":"","url":"https://api.github.com/users/kuza55","html_url":"https://github.com/kuza55","followers_url":"https://api.github.com/users/kuza55/followers","following_url":"https://api.github.com/users/kuza55/following{/other_user}","gists_url":"https://api.github.com/users/kuza55/gists{/gist_id}","starred_url":"https://api.github.com/users/kuza55/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kuza55/subscriptions","organizations_url":"https://api.github.com/users/kuza55/orgs","repos_url":"https://api.github.com/users/kuza55/repos","events_url":"https://api.github.com/users/kuza55/events{/privacy}","received_events_url":"https://api.github.com/users/kuza55/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-09-05T23:20:53Z","updated_at":"2016-09-05T23:23:19Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/fchollet/keras/pulls/3695","html_url":"https://github.com/fchollet/keras/pull/3695","diff_url":"https://github.com/fchollet/keras/pull/3695.diff","patch_url":"https://github.com/fchollet/keras/pull/3695.patch"},"body":""},"comment":{"url":"https://api.github.com/repos/fchollet/keras/issues/comments/244820888","html_url":"https://github.com/fchollet/keras/pull/3695#issuecomment-244820888","issue_url":"https://api.github.com/repos/fchollet/keras/issues/3695","id":244820888,"user":{"login":"kuza55","id":387986,"avatar_url":"https://avatars.githubusercontent.com/u/387986?v=3","gravatar_id":"","url":"https://api.github.com/users/kuza55","html_url":"https://github.com/kuza55","followers_url":"https://api.github.com/users/kuza55/followers","following_url":"https://api.github.com/users/kuza55/following{/other_user}","gists_url":"https://api.github.com/users/kuza55/gists{/gist_id}","starred_url":"https://api.github.com/users/kuza55/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kuza55/subscriptions","organizations_url":"https://api.github.com/users/kuza55/orgs","repos_url":"https://api.github.com/users/kuza55/repos","events_url":"https://api.github.com/users/kuza55/events{/privacy}","received_events_url":"https://api.github.com/users/kuza55/received_events","type":"User","site_admin":false},"created_at":"2016-09-05T23:23:18Z","updated_at":"2016-09-05T23:23:18Z","body":"So, this adds the minimal changes necessary to Keras so that a net can be trained with a scipy.sparse matrix\r\n\r\nThis probably also needs a sparse input layer, but I thought I would get some feedback on this before throwing too much time into it.\r\n\r\nThis is the code I used to test this:\r\n\r\n```\r\nimport numpy as np\r\nimport keras\r\nfrom keras.layers import Input, Dense\r\nfrom keras.models import Model\r\nimport tensorflow as tf\r\n\r\nfrom scipy.sparse import csr_matrix\r\n\r\n#Setup sparse input\r\nx_d = np.array([0, 7, 2, 3], dtype=np.int64)\r\nx_r = np.array([0, 2, 2, 3], dtype=np.int64)\r\nx_c = np.array([4, 3, 2, 3], dtype=np.int64)\r\n\r\ny = np.array([0, 1, 2, 3], dtype=np.int64)\r\n\r\nx_in = csr_matrix((x_d, (x_r, x_c)), shape=(4, 5))\r\n\r\n#Setup Model\r\nnumeric_columns = 5\r\n\r\nsparse = Input(batch_shape=(None, numeric_columns,), tensor=tf.sparse_placeholder(tf.float32))\r\n\r\npredictions = Dense(1, activation='sigmoid')(sparse)\r\n\r\noptimizer = keras.optimizers.Adam()\r\nmodel = Model(input=[sparse], output=predictions)\r\nmodel.compile(loss='binary_crossentropy', optimizer=optimizer, metrics=['accuracy'])\r\n\r\n#Run it!\r\nmodel.fit(x_in, y)\r\n```"}}
{"actor":{"display_login":"kuza55"}}