{"action":"created","issue":{"url":"https://api.github.com/repos/fchollet/keras/issues/5034","repository_url":"https://api.github.com/repos/fchollet/keras","labels_url":"https://api.github.com/repos/fchollet/keras/issues/5034/labels{/name}","comments_url":"https://api.github.com/repos/fchollet/keras/issues/5034/comments","events_url":"https://api.github.com/repos/fchollet/keras/issues/5034/events","html_url":"https://github.com/fchollet/keras/issues/5034","id":200719180,"number":5034,"title":"ImageDataGenerator.flow_from_directory() is outputting the wrong shape data","user":{"login":"mikalyoung","id":5782394,"avatar_url":"https://avatars3.githubusercontent.com/u/5782394?v=3","gravatar_id":"","url":"https://api.github.com/users/mikalyoung","html_url":"https://github.com/mikalyoung","followers_url":"https://api.github.com/users/mikalyoung/followers","following_url":"https://api.github.com/users/mikalyoung/following{/other_user}","gists_url":"https://api.github.com/users/mikalyoung/gists{/gist_id}","starred_url":"https://api.github.com/users/mikalyoung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikalyoung/subscriptions","organizations_url":"https://api.github.com/users/mikalyoung/orgs","repos_url":"https://api.github.com/users/mikalyoung/repos","events_url":"https://api.github.com/users/mikalyoung/events{/privacy}","received_events_url":"https://api.github.com/users/mikalyoung/received_events","type":"User","site_admin":false},"labels":[{"id":611595073,"url":"https://api.github.com/repos/fchollet/keras/labels/stale","name":"stale","color":"ffffff","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-01-13T20:07:53Z","updated_at":"2017-05-23T19:30:51Z","closed_at":null,"body":"From the flow_from_directory tuple output of X_batch and Y_batch, the Y_batch is outputting as a shape that is not one-hot encoding.  The model.fit_generator seems to need one-hot encoding for the labels.  How do you make this in the correct, compatible shape?  This seems to be a bug.\r\n\r\n\r\n```\r\ndatagen = kerasim.ImageDataGenerator(\r\n\t\t        width_shift_range=.1, height_shift_range=.1,  # randomly shift images vertically (fraction of total height)\r\n\t\t        shear_range=0, zoom_range=.15,\r\n\t\t        rescale=None, fill_mode='constant', cval=0.,\r\n\t\t        horizontal_flip=True, vertical_flip=True)\r\n\r\nvaldatagen = kerasim.ImageDataGenerator(\r\n\t\t        width_shift_range=.1, height_shift_range=.1,  # randomly shift images vertically (fraction of total height)\r\n\t\t        shear_range=0, zoom_range=.15,\r\n\t\t        rescale=None, fill_mode='constant', cval=0.,\r\n\t\t        horizontal_flip=True, vertical_flip=True)\r\n\t\t\t\r\ntrain_generator = datagen.flow_from_directory('...', target_size=(256,256), batch_size=batch_size, class_mode='binary')\r\nvalidation_generator = valdatagen.flow_from_directory('...', target_size=(256,256), batch_size=batch_size, class_mode='binary')\r\nmodel.fit_generator(train_generator, samples_per_epoch=2*Nimages, nb_epoch=nb_epoch, \r\n\t\t\t\tvalidation_data=validation_generator, callbacks=callbacks_list, nb_val_samples=100, verbose=1)\r\n\r\n```\r\n\r\nFor my image folders, I have data/train/0, data/train/1, data/validation/0, data/validation/1.  \r\n\r\nError in shape:\r\n\r\n```\r\nEpoch 1/50000\r\nTraceback (most recent call last):\r\n  File \"DR.py\", line 286, in train\r\n    validation_data=validation_generator, callbacks=callbacks_list, nb_val_samples=100, verbose=1)\r\n  File \"/home/sysop/anaconda2/envs/tf/lib/python2.7/site-packages/keras/models.py\", line 935, in fit_generator\r\n    initial_epoch=initial_epoch)\r\n  File \"/home/sysop/anaconda2/envs/tf/lib/python2.7/site-packages/keras/engine/training.py\", line 1518, in fit_generator\r\n    class_weight=class_weight)\r\n  File \"/home/sysop/anaconda2/envs/tf/lib/python2.7/site-packages/keras/engine/training.py\", line 1271, in train_on_batch\r\n    check_batch_axis=True)\r\n  File \"/home/sysop/anaconda2/envs/tf/lib/python2.7/site-packages/keras/engine/training.py\", line 995, in _standardize_user_data\r\n    exception_prefix='model target')\r\n  File \"/home/sysop/anaconda2/envs/tf/lib/python2.7/site-packages/keras/engine/training.py\", line 124, in standardize_input_data\r\n    str(array.shape))\r\nValueError: Error when checking model target: expected predictions to have shape (None, 2) but got array with shape (64, 1)\r\nException in thread Thread-2:\r\n\r\n```\r\n\r\nI am running the latest versions of keras and tensorflow as of today."},"comment":{"url":"https://api.github.com/repos/fchollet/keras/issues/comments/303507200","html_url":"https://github.com/fchollet/keras/issues/5034#issuecomment-303507200","issue_url":"https://api.github.com/repos/fchollet/keras/issues/5034","id":303507200,"user":{"login":"probot-stale[bot]","id":26384082,"avatar_url":"https://avatars1.githubusercontent.com/u/26350515?v=3","gravatar_id":"","url":"https://api.github.com/users/probot-stale%5Bbot%5D","html_url":"https://github.com/app/probot-stale","followers_url":"https://api.github.com/users/probot-stale%5Bbot%5D/followers","following_url":"https://api.github.com/users/probot-stale%5Bbot%5D/following{/other_user}","gists_url":"https://api.github.com/users/probot-stale%5Bbot%5D/gists{/gist_id}","starred_url":"https://api.github.com/users/probot-stale%5Bbot%5D/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/probot-stale%5Bbot%5D/subscriptions","organizations_url":"https://api.github.com/users/probot-stale%5Bbot%5D/orgs","repos_url":"https://api.github.com/users/probot-stale%5Bbot%5D/repos","events_url":"https://api.github.com/users/probot-stale%5Bbot%5D/events{/privacy}","received_events_url":"https://api.github.com/users/probot-stale%5Bbot%5D/received_events","type":"Bot","site_admin":false},"created_at":"2017-05-23T19:30:51Z","updated_at":"2017-05-23T19:30:51Z","body":"This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs, but feel free to re-open it if needed.\n"}}
{"actor":{"display_login":"probot-stale"}}