{"action":"created","issue":{"url":"https://api.github.com/repos/tensorflow/tensorflow/issues/5886","repository_url":"https://api.github.com/repos/tensorflow/tensorflow","labels_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/5886/labels{/name}","comments_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/5886/comments","events_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/5886/events","html_url":"https://github.com/tensorflow/tensorflow/issues/5886","id":191877416,"number":5886,"title":"Crash with dynamic tf.reshape \"Check failed: dtype() == expected_dtype (9 vs. 3)\"","user":{"login":"bodokaiser","id":1780466,"avatar_url":"https://avatars.githubusercontent.com/u/1780466?v=3","gravatar_id":"","url":"https://api.github.com/users/bodokaiser","html_url":"https://github.com/bodokaiser","followers_url":"https://api.github.com/users/bodokaiser/followers","following_url":"https://api.github.com/users/bodokaiser/following{/other_user}","gists_url":"https://api.github.com/users/bodokaiser/gists{/gist_id}","starred_url":"https://api.github.com/users/bodokaiser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bodokaiser/subscriptions","organizations_url":"https://api.github.com/users/bodokaiser/orgs","repos_url":"https://api.github.com/users/bodokaiser/repos","events_url":"https://api.github.com/users/bodokaiser/events{/privacy}","received_events_url":"https://api.github.com/users/bodokaiser/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-11-27T18:48:50Z","updated_at":"2016-11-27T19:51:17Z","closed_at":null,"body":"```py\r\nimport tensorflow as tf\r\n\r\nqueue = tf.train.string_input_producer(['data.tfrecord'])\r\n\r\nreader = tf.TFRecordReader()\r\n_, example = reader.read(queue)\r\n\r\nfeatures = tf.parse_single_example(example,features={\r\n    'mr_image': tf.FixedLenFeature([], tf.string),\r\n    'us_image': tf.FixedLenFeature([], tf.string),\r\n    'mr_shape': tf.FixedLenFeature([2], tf.int64),\r\n    'us_shape': tf.FixedLenFeature([2], tf.int64),\r\n})\r\n\r\nmr_image = tf.decode_raw(features['mr_image'], tf.int16)\r\nus_image = tf.decode_raw(features['us_image'], tf.uint8)\r\n\r\nmr_shape = tf.cast(features['mr_shape'], tf.int64)\r\nus_shape = tf.cast(features['us_shape'], tf.int64)\r\n\r\nwith tf.Session() as sess:\r\n    coord = tf.train.Coordinator()\r\n    threads = tf.train.start_queue_runners(sess=sess, coord=coord)\r\n    \r\n    #mr = tf.reshape(mr_image, mr_shape)\r\n    #us = tf.reshape(us_image, us_shape)\r\n\r\n    print(len(sess.run(mr_image)),len(sess.run(us_image)))\r\n    print(sess.run([mr_shape, us_shape]))\r\n    #print(sess.run(tf.reshape(mr_image, mr_shape)))\r\n    \r\n    coord.request_stop()\r\n    coord.join(threads)\r\n```\r\n\r\nWill print:\r\n```\r\n183604 118218\r\n[array([466, 394]), array([366, 323])]\r\n```\r\n\r\nHowever `print(sess.run(tf.reshape(mr_image, mr_shape)))` will cause a crash with:\r\n```sh\r\nF tensorflow/core/framework/tensor.cc:441] Check failed: dtype() == expected_dtype (9 vs. 3)\r\n```\r\n\r\nAlso `print(sess.run(tf.reshape(mr_image, [466, 394])))` works as expected.\r\n\r\n- macOS 10.12.1\r\n- Python 3.5.2\r\n- tensorflow 0.11"},"comment":{"url":"https://api.github.com/repos/tensorflow/tensorflow/issues/comments/263143040","html_url":"https://github.com/tensorflow/tensorflow/issues/5886#issuecomment-263143040","issue_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/5886","id":263143040,"user":{"login":"prb12","id":11547801,"avatar_url":"https://avatars.githubusercontent.com/u/11547801?v=3","gravatar_id":"","url":"https://api.github.com/users/prb12","html_url":"https://github.com/prb12","followers_url":"https://api.github.com/users/prb12/followers","following_url":"https://api.github.com/users/prb12/following{/other_user}","gists_url":"https://api.github.com/users/prb12/gists{/gist_id}","starred_url":"https://api.github.com/users/prb12/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prb12/subscriptions","organizations_url":"https://api.github.com/users/prb12/orgs","repos_url":"https://api.github.com/users/prb12/repos","events_url":"https://api.github.com/users/prb12/events{/privacy}","received_events_url":"https://api.github.com/users/prb12/received_events","type":"User","site_admin":false},"created_at":"2016-11-27T19:51:17Z","updated_at":"2016-11-27T19:51:17Z","body":"Thanks for reporting the issue. It looks from your report that this is a runtime failure, rather than a Python exception.\r\n\r\nThe docs for `tf.reshape` state that the new shape is allowed to be int32 or int64:\r\nhttps://www.tensorflow.org/versions/r0.11/api_docs/python/array_ops.html#reshape\r\nand the op is correctly registered:\r\nhttps://github.com/tensorflow/tensorflow/blob/r0.11/tensorflow/core/ops/array_ops.cc#L1155\r\n\r\nHowever, unless I'm missing something it looks like the implementation of the OpKernel assumes that the `sizes` are `int32`:\r\nhttps://github.com/tensorflow/tensorflow/blob/r0.11/tensorflow/core/kernels/reshape_op.h#L48\r\n\r\nThis seems to have been the case for a *long* time!  \r\n\r\nAs a workaround, you could simple use int32 shapes, but either the documentation or implementation should probably be fixed.\r\n"}}
{"actor":{"display_login":"prb12"}}