{"action":"created","issue":{"url":"https://api.github.com/repos/keras-team/keras/issues/2397","repository_url":"https://api.github.com/repos/keras-team/keras","labels_url":"https://api.github.com/repos/keras-team/keras/issues/2397/labels{/name}","comments_url":"https://api.github.com/repos/keras-team/keras/issues/2397/comments","events_url":"https://api.github.com/repos/keras-team/keras/issues/2397/events","html_url":"https://github.com/keras-team/keras/issues/2397","id":149397212,"node_id":"MDU6SXNzdWUxNDkzOTcyMTI=","number":2397,"title":"Tensorflow backend - bug in model._make_predict_function(...)","user":{"login":"Froskekongen","id":4319052,"node_id":"MDQ6VXNlcjQzMTkwNTI=","avatar_url":"https://avatars1.githubusercontent.com/u/4319052?v=4","gravatar_id":"","url":"https://api.github.com/users/Froskekongen","html_url":"https://github.com/Froskekongen","followers_url":"https://api.github.com/users/Froskekongen/followers","following_url":"https://api.github.com/users/Froskekongen/following{/other_user}","gists_url":"https://api.github.com/users/Froskekongen/gists{/gist_id}","starred_url":"https://api.github.com/users/Froskekongen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Froskekongen/subscriptions","organizations_url":"https://api.github.com/users/Froskekongen/orgs","repos_url":"https://api.github.com/users/Froskekongen/repos","events_url":"https://api.github.com/users/Froskekongen/events{/privacy}","received_events_url":"https://api.github.com/users/Froskekongen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":66,"created_at":"2016-04-19T09:08:30Z","updated_at":"2018-08-13T17:31:43Z","closed_at":null,"author_association":"NONE","body":"There appears to be a bug in the make_predict_function for the tensorflow backend. The following error message appears for me when trying to call model.predict(...)\n\n```\nself._make_predict_function()\n  File \"/usr/local/lib/python3.4/dist-packages/keras/engine/training.py\", line 679, in _make_predict_function\n    **self._function_kwargs)\n  File \"/usr/local/lib/python3.4/dist-packages/keras/backend/tensorflow_backend.py\", line 615, in function\n    return Function(inputs, outputs, updates=updates)\n  File \"/usr/local/lib/python3.4/dist-packages/keras/backend/tensorflow_backend.py\", line 589, in __init__\n    with tf.control_dependencies(self.outputs):\n  File \"/usr/local/lib/python3.4/dist-packages/tensorflow/python/framework/ops.py\", line 3192, in control_dependencies\n    return get_default_graph().control_dependencies(control_inputs)\n  File \"/usr/local/lib/python3.4/dist-packages/tensorflow/python/framework/ops.py\", line 2993, in control_dependencies\n    c = self.as_graph_element(c)\n  File \"/usr/local/lib/python3.4/dist-packages/tensorflow/python/framework/ops.py\", line 2291, in as_graph_element\n    raise ValueError(\"Tensor %s is not an element of this graph.\" % obj)\nValueError: Tensor Tensor(\"Sigmoid_2:0\", shape=(?, 17), dtype=float32) is not an element of this graph.\n```\n\nThis does not happen when using the theano backend.\n\nNotes: The model is loaded from json, and is defined as follows:\n\n```\n    seq1=Input(dtype='int32',shape=(400,),name='input_text')\n    seq2=Input(dtype='int32',shape=(20,),name='input_titles')\n\n    embeddeding=Embedding(max_features,embedding_dims,dropout=0.3)\n\n    encoding_1=embeddeding(seq1)\n    encoding_2=embeddeding(seq2)\n\n    filter_lengths = [1,3,6]\n\n\n    def max_1d(X):\n        return K.max(X, axis=1)\n    convs1=[]\n    convs2=[]\n    for fl in filter_lengths:\n\n        conv1=Convolution1D(nb_filter=nb_filter,\n                        filter_length=fl,\n                        border_mode='valid',\n                        activation='relu',\n                        subsample_length=1)(encoding_1)\n        conv1=Lambda(max_1d, output_shape=(nb_filter,))(conv1)\n        convs1.append(conv1)\n\n        conv2=Convolution1D(nb_filter=nb_filter,\n                        filter_length=fl,\n                        border_mode='valid',\n                        activation='relu',\n                        subsample_length=1)(encoding_2)\n        conv2=Lambda(max_1d, output_shape=(nb_filter,))(conv2)\n        convs2.append(conv2)\n\n    m=merge([*convs1,*convs2],mode='concat')\n    m=Highway(activation='relu')(m)\n    m=Highway(activation='relu')(m)\n    m=Dropout(0.5)(m)\n    hovedkategori_loss=Dense(labsHovedKat.shape[1],activation='sigmoid',name='hovedkategori')(m)\n\n    m1=merge([hovedkategori_loss,m],mode='concat')\n    underkategori_loss=Dense(labsUnderKat.shape[1],activation='sigmoid',name='underkategori')(m1)\n\n    model=Model(input=[seq1,seq2],output=[hovedkategori_loss,underkategori_loss])\n    model.compile(optimizer='adam',loss='binary_crossentropy',metrics={'hovedkategori':'accuracy','underkategori':'accuracy'})\n```\n- [x] Check that you are up-to-date with the master branch of Keras. You can update with:\n  pip install git+git://github.com/fchollet/keras.git --upgrade --no-deps\n- [x] If running on Theano, check that you are up-to-date with the master branch of Theano. You can update with:\n  pip install git+git://github.com/Theano/Theano.git --upgrade --no-deps\n"},"comment":{"url":"https://api.github.com/repos/keras-team/keras/issues/comments/412599569","html_url":"https://github.com/keras-team/keras/issues/2397#issuecomment-412599569","issue_url":"https://api.github.com/repos/keras-team/keras/issues/2397","id":412599569,"node_id":"MDEyOklzc3VlQ29tbWVudDQxMjU5OTU2OQ==","user":{"login":"zoltan-fedor","id":3887295,"node_id":"MDQ6VXNlcjM4ODcyOTU=","avatar_url":"https://avatars2.githubusercontent.com/u/3887295?v=4","gravatar_id":"","url":"https://api.github.com/users/zoltan-fedor","html_url":"https://github.com/zoltan-fedor","followers_url":"https://api.github.com/users/zoltan-fedor/followers","following_url":"https://api.github.com/users/zoltan-fedor/following{/other_user}","gists_url":"https://api.github.com/users/zoltan-fedor/gists{/gist_id}","starred_url":"https://api.github.com/users/zoltan-fedor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zoltan-fedor/subscriptions","organizations_url":"https://api.github.com/users/zoltan-fedor/orgs","repos_url":"https://api.github.com/users/zoltan-fedor/repos","events_url":"https://api.github.com/users/zoltan-fedor/events{/privacy}","received_events_url":"https://api.github.com/users/zoltan-fedor/received_events","type":"User","site_admin":false},"created_at":"2018-08-13T17:31:43Z","updated_at":"2018-08-13T17:31:43Z","author_association":"NONE","body":"In Flask I had to move my Rasa Agent setup code (which is using Keras with Tensorflow backend to predict) to the @app.before_first_request and then store the agent in the app variable to fix this issue for my project.\r\nThank for everybody contributing above, it helped me a lot."}}
{"actor":{"display_login":"zoltan-fedor"}}