payload: {"action":"created","issue":{"url":"https://api.github.com/repos/tensorflow/probability/issues/282","repository_url":"https://api.github.com/repos/tensorflow/probability","labels_url":"https://api.github.com/repos/tensorflow/probability/issues/282/labels{/name}","comments_url":"https://api.github.com/repos/tensorflow/probability/issues/282/comments","events_url":"https://api.github.com/repos/tensorflow/probability/issues/282/events","html_url":"https://github.com/tensorflow/probability/issues/282","id":403801228,"node_id":"MDU6SXNzdWU0MDM4MDEyMjg=","number":282,"title":"Keras model.compile uses incorrect loss when using Bayesian layers.","user":{"login":"xht033","id":14569253,"node_id":"MDQ6VXNlcjE0NTY5MjUz","avatar_url":"https://avatars2.githubusercontent.com/u/14569253?v=4","gravatar_id":"","url":"https://api.github.com/users/xht033","html_url":"https://github.com/xht033","followers_url":"https://api.github.com/users/xht033/followers","following_url":"https://api.github.com/users/xht033/following{/other_user}","gists_url":"https://api.github.com/users/xht033/gists{/gist_id}","starred_url":"https://api.github.com/users/xht033/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xht033/subscriptions","organizations_url":"https://api.github.com/users/xht033/orgs","repos_url":"https://api.github.com/users/xht033/repos","events_url":"https://api.github.com/users/xht033/events{/privacy}","received_events_url":"https://api.github.com/users/xht033/received_events","type":"User","site_admin":false},"labels":[{"id":1197738888,"node_id":"MDU6TGFiZWwxMTk3NzM4ODg4","url":"https://api.github.com/repos/tensorflow/probability/labels/layers","name":"layers","color":"e1f453","default":false}],"state":"open","locked":false,"assignee":{"login":"jburnim","id":347375,"node_id":"MDQ6VXNlcjM0NzM3NQ==","avatar_url":"https://avatars0.githubusercontent.com/u/347375?v=4","gravatar_id":"","url":"https://api.github.com/users/jburnim","html_url":"https://github.com/jburnim","followers_url":"https://api.github.com/users/jburnim/followers","following_url":"https://api.github.com/users/jburnim/following{/other_user}","gists_url":"https://api.github.com/users/jburnim/gists{/gist_id}","starred_url":"https://api.github.com/users/jburnim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jburnim/subscriptions","organizations_url":"https://api.github.com/users/jburnim/orgs","repos_url":"https://api.github.com/users/jburnim/repos","events_url":"https://api.github.com/users/jburnim/events{/privacy}","received_events_url":"https://api.github.com/users/jburnim/received_events","type":"User","site_admin":false},"assignees":[{"login":"jburnim","id":347375,"node_id":"MDQ6VXNlcjM0NzM3NQ==","avatar_url":"https://avatars0.githubusercontent.com/u/347375?v=4","gravatar_id":"","url":"https://api.github.com/users/jburnim","html_url":"https://github.com/jburnim","followers_url":"https://api.github.com/users/jburnim/followers","following_url":"https://api.github.com/users/jburnim/following{/other_user}","gists_url":"https://api.github.com/users/jburnim/gists{/gist_id}","starred_url":"https://api.github.com/users/jburnim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jburnim/subscriptions","organizations_url":"https://api.github.com/users/jburnim/orgs","repos_url":"https://api.github.com/users/jburnim/repos","events_url":"https://api.github.com/users/jburnim/events{/privacy}","received_events_url":"https://api.github.com/users/jburnim/received_events","type":"User","site_admin":false}],"milestone":null,"comments":1,"created_at":"2019-01-28T12:57:41Z","updated_at":"2019-06-21T00:55:49Z","closed_at":null,"author_association":"NONE","body":"When I use my custom loss function, I got a wrong loss output if I choose keras.compile:\r\n\r\n```\r\nimport tensorflow as tf\r\n\r\nfrom tensorflow.examples.tutorials.mnist import input_data as mnist_data\r\n\r\ntrain, valid, test = mnist_data.read_data_sets('~/code/Python')\r\nnum_classes = 10\r\nfrom tensorflow import keras\r\nimport tensorflow_probability as tfp\r\nmodel = keras.Sequential()\r\n\r\nmodel.add(tfp.layers.DenseReparameterization(10, activation = 'softmax', input_shape=(784,)))\r\n\r\nsgd = keras.optimizers.SGD(lr=.1, momentum=0.9, nesterov=True)\r\ndef my_loss(y_true,y_pred):\r\n    return tf.keras.losses.categorical_crossentropy(y_true,y_pred)\r\nmodel.compile(loss=my_loss, optimizer=sgd, metrics=['accuracy'])\r\n\r\nx_train, y_train = train.images, train.labels\r\nx_test, y_test = test.images, test.labels\r\n\r\ny_train = keras.utils.to_categorical(y_train, num_classes)\r\ny_test = keras.utils.to_categorical(y_test, num_classes)\r\nmodel.fit(x_train, y_train,\r\n              batch_size=128,\r\n              epochs=10,\r\n              validation_data=(x_test, y_test),\r\n              shuffle=True)\r\n```\r\n\r\nHowever, If I replace the bayesian layer by a traditional Dense layer, it seems everything is correct. "},"comment":{"url":"https://api.github.com/repos/tensorflow/probability/issues/comments/504249650","html_url":"https://github.com/tensorflow/probability/issues/282#issuecomment-504249650","issue_url":"https://api.github.com/repos/tensorflow/probability/issues/282","id":504249650,"node_id":"MDEyOklzc3VlQ29tbWVudDUwNDI0OTY1MA==","user":{"login":"xht033","id":14569253,"node_id":"MDQ6VXNlcjE0NTY5MjUz","avatar_url":"https://avatars2.githubusercontent.com/u/14569253?v=4","gravatar_id":"","url":"https://api.github.com/users/xht033","html_url":"https://github.com/xht033","followers_url":"https://api.github.com/users/xht033/followers","following_url":"https://api.github.com/users/xht033/following{/other_user}","gists_url":"https://api.github.com/users/xht033/gists{/gist_id}","starred_url":"https://api.github.com/users/xht033/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xht033/subscriptions","organizations_url":"https://api.github.com/users/xht033/orgs","repos_url":"https://api.github.com/users/xht033/repos","events_url":"https://api.github.com/users/xht033/events{/privacy}","received_events_url":"https://api.github.com/users/xht033/received_events","type":"User","site_admin":false},"created_at":"2019-06-21T00:55:49Z","updated_at":"2019-06-21T00:55:49Z","author_association":"NONE","body":"Can I ask why we divide the total number of training_data_set? \r\n"}}
other: {"actor":{"display_login":"xht033"}}