keras

AttributeError: module 'tensorflow' has no attribute 'get_default_graph'

扶醉桌前 提交于 2020-12-25 04:09:42
问题 I am doing some task related to image captioning and I have loaded the weights of inception model like this model = InceptionV3(weights='imagenet') But I am getting error like this: AttributeError: module 'tensorflow' has no attribute 'get_default_graph' What should I do? Please help. Here is the full output of above code. 1 . --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) in () 1 # Load the inception v3 model ---->

Does Any one got “AttributeError: 'str' object has no attribute 'decode' ” , while Loading a Keras Saved Model

半城伤御伤魂 提交于 2020-12-25 00:33:58
问题 After Training, I saved Both Keras whole Model and Only Weights using model.save_weights(MODEL_WEIGHTS) and model.save(MODEL_NAME) Models and Weights were saved successfully and there was no error. I can successfully load the weights simply using model.load_weights and they are good to go, but when i try to load the save model via load_model, i am getting an error. File "C:/Users/Rizwan/model_testing/model_performance.py", line 46, in <module> Model2 = load_model('nasnet_RS2.h5',custom

Does Any one got “AttributeError: 'str' object has no attribute 'decode' ” , while Loading a Keras Saved Model

 ̄綄美尐妖づ 提交于 2020-12-25 00:29:59
问题 After Training, I saved Both Keras whole Model and Only Weights using model.save_weights(MODEL_WEIGHTS) and model.save(MODEL_NAME) Models and Weights were saved successfully and there was no error. I can successfully load the weights simply using model.load_weights and they are good to go, but when i try to load the save model via load_model, i am getting an error. File "C:/Users/Rizwan/model_testing/model_performance.py", line 46, in <module> Model2 = load_model('nasnet_RS2.h5',custom

Should the custom loss function in Keras return a single loss value for the batch or an arrary of losses for every sample in the training batch?

不想你离开。 提交于 2020-12-23 09:40:26
问题 I'm learning keras API in tensorflow(2.3). In this guide on tensorflow website, I found an example of custom loss funciton: def custom_mean_squared_error(y_true, y_pred): return tf.math.reduce_mean(tf.square(y_true - y_pred)) The reduce_mean function in this custom loss function will return an scalar. Is it right to define loss function like this? As far as I know, the first dimension of the shapes of y_true and y_pred is the batch size. I think the loss function should return loss values for

Create an LSTM layer with Attention in Keras for multi-label text classification neural network

笑着哭i 提交于 2020-12-23 06:49:49
问题 Greetings dear members of the community. I am creating a neural network to predict a multi-label y. Specifically, the neural network takes 5 inputs (list of actors, plot summary, movie features, movie reviews, title) and tries to predict the sequence of movie genres. In the neural network I use Embeddings Layer and Global Max Pooling layers. However, I recently discovered the Recurrent Layers with Attention, which are a very interesting topic these days in machine learning translation. So, I

Why the model is training on only 1875 training set images if there are 60000 images in the MNIST dataset? [duplicate]

折月煮酒 提交于 2020-12-21 04:22:20
问题 This question already has answers here : TensorFlow Only running on 1/32 of the Training data provided (1 answer) Keras not training on entire dataset (2 answers) Training MNIST data set in google colab issue: [duplicate] (2 answers) actual training samples and samples visible in epochs while running are different [duplicate] (1 answer) Model fitting doesn't use all of the provided data [duplicate] (1 answer) Closed 7 months ago . I am trying to create a simple CNN to classify images in MNIST

TensorFlow Only running on 1/32 of the Training data provided

久未见 提交于 2020-12-17 09:36:48
问题 I've implemented a neural network using tensor flow and it appears to be only running on 1/32 data points. I've then tried to following simple example to see if it was me: https://pythonprogramming.net/introduction-deep-learning-python-tensorflow-keras/ Even when using identical (copied and pasted) code I still get 1/32 of the training data being processed e.g. Epoch 3/3 1875/1875 [==============================] - 2s 961us/step - loss: 0.0733 - accuracy: 0.9773 instead of the following which

TensorFlow Only running on 1/32 of the Training data provided

喜你入骨 提交于 2020-12-17 09:29:40
问题 I've implemented a neural network using tensor flow and it appears to be only running on 1/32 data points. I've then tried to following simple example to see if it was me: https://pythonprogramming.net/introduction-deep-learning-python-tensorflow-keras/ Even when using identical (copied and pasted) code I still get 1/32 of the training data being processed e.g. Epoch 3/3 1875/1875 [==============================] - 2s 961us/step - loss: 0.0733 - accuracy: 0.9773 instead of the following which

Validation accuracy metrics reported by Keras model.fit log and Sklearn.metrics.confusion_matrix don't match each other

别来无恙 提交于 2020-12-15 06:29:10
问题 The problem is that the reported validation accuracy value I get from Keras model.fit history is significantly higher than the validation accuracy metric I get from sklearn.metrics functions. The results I get from model.fit are summarized below: Last Validation Accuracy: 0.81 Best Validation Accuracy: 0.84 The results (normalized) from sklearn are pretty different: True Negatives: 0.78 True Positives: 0.77 Validation Accuracy = (TP + TN) / (TP + TN + FP + FN) = 0.775 (see confusion matrix

ValueError : Input 0 of layer lstm is incompatible with the layer: expected ndim=3, found ndim=2. Full shape received: [None, 18]

女生的网名这么多〃 提交于 2020-12-15 06:08:52
问题 I'm new with Keras and I'm trying to build a model for personal use/future learning. I've just started with python and I came up with this code (with help of videos and tutorials). I have a data of 16324 instances, each instance consists of 18 features and 1 dependent variable. import pandas as pd import os import time import tensorflow as tf from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense, Dropout, LSTM, BatchNormalization from tensorflow.keras