{"action":"created","issue":{"url":"https://api.github.com/repos/tensorflow/tensorflow/issues/16197","repository_url":"https://api.github.com/repos/tensorflow/tensorflow","labels_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/16197/labels{/name}","comments_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/16197/comments","events_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/16197/events","html_url":"https://github.com/tensorflow/tensorflow/issues/16197","id":289403924,"number":16197,"title":"add broadcasting to `softmax_cross_entropy_with_logits`","user":{"login":"csbrown","id":1459444,"avatar_url":"https://avatars0.githubusercontent.com/u/1459444?v=4","gravatar_id":"","url":"https://api.github.com/users/csbrown","html_url":"https://github.com/csbrown","followers_url":"https://api.github.com/users/csbrown/followers","following_url":"https://api.github.com/users/csbrown/following{/other_user}","gists_url":"https://api.github.com/users/csbrown/gists{/gist_id}","starred_url":"https://api.github.com/users/csbrown/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/csbrown/subscriptions","organizations_url":"https://api.github.com/users/csbrown/orgs","repos_url":"https://api.github.com/users/csbrown/repos","events_url":"https://api.github.com/users/csbrown/events{/privacy}","received_events_url":"https://api.github.com/users/csbrown/received_events","type":"User","site_admin":false},"labels":[{"id":404586594,"url":"https://api.github.com/repos/tensorflow/tensorflow/labels/stat:awaiting%20tensorflower","name":"stat:awaiting tensorflower","color":"b60205","default":false},{"id":473173272,"url":"https://api.github.com/repos/tensorflow/tensorflow/labels/type:feature","name":"type:feature","color":"c2e0c6","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2018-01-17T20:33:07Z","updated_at":"2018-03-17T15:45:08Z","closed_at":"2018-03-17T15:45:08Z","author_association":"NONE","body":"\r\n### System information\r\n- **Have I written custom code (as opposed to using a stock example script provided in TensorFlow)**: yeah\r\n- **OS Platform and Distribution (e.g., Linux Ubuntu 16.04)**: ubuntu 16.04\r\n- **TensorFlow installed from (source or binary)**: pip3 binary\r\n- **TensorFlow version (use command below)**:\r\n```\r\n>>> tf.__git_version__\r\n'v1.4.0-rc1-11-g130a514'\r\n>>> tf.__version__\r\n'1.4.0'\r\n```\r\n- **Python version**: 3.5.2\r\n- **Bazel version (if compiling from source)**:\r\n- **GCC/Compiler version (if compiling from source)**:\r\n- **CUDA/cuDNN version**: NA\r\n- **GPU model and memory**: NA\r\n- **Exact command to reproduce**: tf.nn.softmax_cross_entropy_with_logits(labels=tf.constant(1., shape=(2,)), logits=tf.constant(1., shape=(50,2)))\r\n\r\n\r\n### Describe the problem\r\nFEATURE REQUEST: `softmax_cross_entropy_with_logits` should broadcast, maybe?  I'm reading groups of data that all have the same label.  Seems a waste to have to replicate the label a gazillion times.\r\n\r\n### Source code / logs\r\n```\r\n>>> a = tf.nn.softmax_cross_entropy_with_logits(labels=tf.constant(1., shape=(2,)), logits=tf.constant(1., shape=(50,2)))\r\n\r\nTraceback (most recent call last):\r\n  File \"/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/common_shapes.py\", line 686, in _call_cpp_shape_fn_impl\r\n    input_tensors_as_shapes, status)\r\n  File \"/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/errors_impl.py\", line 473, in __exit__\r\n    c_api.TF_GetCode(self.status.status))\r\ntensorflow.python.framework.errors_impl.InvalidArgumentError: Dimension 0 in both shapes must be equal, but are 50 and 1 for 'SoftmaxCrossEntropyWithLogits_3' (op: 'SoftmaxCrossEntropyWithLogits') with input shapes: [50,2], [1,2].\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nTraceback (most recent call last):\r\n  File \"<stdin>\", line 1, in <module>\r\n  File \"/usr/local/lib/python3.5/dist-packages/tensorflow/python/ops/nn_ops.py\", line 1783, in softmax_cross_entropy_with_logits\r\n    precise_logits, labels, name=name)\r\n  File \"/usr/local/lib/python3.5/dist-packages/tensorflow/python/ops/gen_nn_ops.py\", line 4364, in _softmax_cross_entropy_with_logits\r\n    name=name)\r\n  File \"/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/op_def_library.py\", line 787, in _apply_op_helper\r\n    op_def=op_def)\r\n  File \"/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/ops.py\", line 2958, in create_op\r\n    set_shapes_for_outputs(ret)\r\n  File \"/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/ops.py\", line 2209, in set_shapes_for_outputs\r\n    shapes = shape_func(op)\r\n  File \"/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/ops.py\", line 2159, in call_with_requiring\r\n    return call_cpp_shape_fn(op, require_shape_fn=True)\r\n  File \"/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/common_shapes.py\", line 627, in call_cpp_shape_fn\r\n    require_shape_fn)\r\n  File \"/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/common_shapes.py\", line 691, in _call_cpp_shape_fn_impl\r\n    raise ValueError(err.message)\r\nValueError: Dimension 0 in both shapes must be equal, but are 50 and 1 for 'SoftmaxCrossEntropyWithLogits_3' (op: 'SoftmaxCrossEntropyWithLogits') with input shapes: [50,2], [1,2].\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/tensorflow/tensorflow/issues/comments/373929918","html_url":"https://github.com/tensorflow/tensorflow/issues/16197#issuecomment-373929918","issue_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/16197","id":373929918,"user":{"login":"ebrevdo","id":1794715,"avatar_url":"https://avatars0.githubusercontent.com/u/1794715?v=4","gravatar_id":"","url":"https://api.github.com/users/ebrevdo","html_url":"https://github.com/ebrevdo","followers_url":"https://api.github.com/users/ebrevdo/followers","following_url":"https://api.github.com/users/ebrevdo/following{/other_user}","gists_url":"https://api.github.com/users/ebrevdo/gists{/gist_id}","starred_url":"https://api.github.com/users/ebrevdo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ebrevdo/subscriptions","organizations_url":"https://api.github.com/users/ebrevdo/orgs","repos_url":"https://api.github.com/users/ebrevdo/repos","events_url":"https://api.github.com/users/ebrevdo/events{/privacy}","received_events_url":"https://api.github.com/users/ebrevdo/received_events","type":"User","site_admin":false},"created_at":"2018-03-17T15:45:08Z","updated_at":"2018-03-17T15:45:08Z","author_association":"CONTRIBUTOR","body":"I agree that for now, tiling manually is the best approach. A recent change to broadcasting in a similar softmax op caused invisible/subtle errors."}}
{"actor":{"display_login":"ebrevdo"}}