keras

CTC LOSS ERROR InvalidArgumentError: Not enough time for target transition sequence

99封情书 提交于 2021-02-18 19:52:12
问题 CTC LOSS ERROR InvalidArgumentError: Not enough time for target transition sequence 回答1: your ground-truth (GT) text is too long. Your input matrix for the CTC loss function has a time-axis with length T. Your GT text must not be longer than T. Example: input matrix has length 4, your GT text is "world" with length 5, then there is no way that the matrix can contain this text, because it can encode at most 4 chars. If the GT text contains duplicate chars (like in pi zz a), then the CTC

CTC LOSS ERROR InvalidArgumentError: Not enough time for target transition sequence

牧云@^-^@ 提交于 2021-02-18 19:48:54
问题 CTC LOSS ERROR InvalidArgumentError: Not enough time for target transition sequence 回答1: your ground-truth (GT) text is too long. Your input matrix for the CTC loss function has a time-axis with length T. Your GT text must not be longer than T. Example: input matrix has length 4, your GT text is "world" with length 5, then there is no way that the matrix can contain this text, because it can encode at most 4 chars. If the GT text contains duplicate chars (like in pi zz a), then the CTC

Converting pretrained saved model from NCHW to NHWC to make it compatible for Tensorflow Lite

本秂侑毒 提交于 2021-02-18 19:21:46
问题 I have converted a model from PyTorch to Keras and used the backend to extract the tensorflow graph. Since the data format for PyTorch was NCHW, the model extracted and saved is also that. While converting the model to TFLite, due to the format being NCHW, it cannot get converted. Is there a way to convert the whole graph into NHCW? 回答1: It is better to have a graph with the data-format matched to TFLite for faster inference. One approach is to manually insert transpose ops into the graph,

How to remove layers from a keras model in order to use as baseline for creating another model

五迷三道 提交于 2021-02-18 19:11:14
问题 I need to use a pre-trained model in Keras(keras.applications.VGG16) as a baseline for creating another model(for doing transfer learning) from the first layers of it. The end goal is to freeze and export the model for deployment on a raspberry pi with AIY vision kit. I've tried the common approach of: model_base = keras.applications.VGG16(input_tensor=inputs) x = model_base.get_layer(backbone_layer).output x = keras.layers.Flatten()(x) x = keras.layers.Dense(1)(x) model = keras.models.Model

ImportError: DLL load failed while importing _pywrap_tensorflow_internal: The specified module could not be found [duplicate]

那年仲夏 提交于 2021-02-18 19:07:50
问题 This question already has an answer here : can't import tensorflow in python, windows 10 64 bit (1 answer) Closed 7 months ago . I am trying to make a simple LSTM time-series model for predicting future prices using the past prices. I am getting error while running the code. I have imported keras in my code but I have not imported tensorflow directly. It shows the below error: Traceback (most recent call last): File "pricePredictor.py", line 29, in <module> from keras.models import Sequential

ImportError: DLL load failed while importing _pywrap_tensorflow_internal: The specified module could not be found [duplicate]

偶尔善良 提交于 2021-02-18 19:03:13
问题 This question already has an answer here : can't import tensorflow in python, windows 10 64 bit (1 answer) Closed 7 months ago . I am trying to make a simple LSTM time-series model for predicting future prices using the past prices. I am getting error while running the code. I have imported keras in my code but I have not imported tensorflow directly. It shows the below error: Traceback (most recent call last): File "pricePredictor.py", line 29, in <module> from keras.models import Sequential

Save/load a keras model with constants

自古美人都是妖i 提交于 2021-02-18 18:57:11
问题 I have a Keras model where I'd like to add a constant to the predictions. After some googling, I've ended up with the following code, which does exactly what I want: import numpy as np from keras.layers import Input, Add from keras.backend import variable from keras.models import Model, load_model inputs = Input(shape=(1,)) add_in = Input(tensor=variable([[5]]), name='add') output = Add()([inputs, add_in]) model = Model([inputs, add_in], output) model.compile(loss='mse', optimizer='adam') X =

Save/load a keras model with constants

房东的猫 提交于 2021-02-18 18:56:04
问题 I have a Keras model where I'd like to add a constant to the predictions. After some googling, I've ended up with the following code, which does exactly what I want: import numpy as np from keras.layers import Input, Add from keras.backend import variable from keras.models import Model, load_model inputs = Input(shape=(1,)) add_in = Input(tensor=variable([[5]]), name='add') output = Add()([inputs, add_in]) model = Model([inputs, add_in], output) model.compile(loss='mse', optimizer='adam') X =

How to save best model in Keras based on AUC metric?

走远了吗. 提交于 2021-02-18 18:00:33
问题 I would like to save the best model in Keras based on auc and I have this code: def MyMetric(yTrue, yPred): auc = tf.metrics.auc(yTrue, yPred) return auc best_model = [ModelCheckpoint(filepath='best_model.h5', monitor='MyMetric', save_best_only=True)] train_history = model.fit([train_x], [train_y], batch_size=batch_size, epochs=epochs, validation_split=0.05, callbacks=best_model, verbose = 2) SO my model runs nut I get this warning: RuntimeWarning: Can save best model only with MyMetric

How to save best model in Keras based on AUC metric?

走远了吗. 提交于 2021-02-18 17:59:28
问题 I would like to save the best model in Keras based on auc and I have this code: def MyMetric(yTrue, yPred): auc = tf.metrics.auc(yTrue, yPred) return auc best_model = [ModelCheckpoint(filepath='best_model.h5', monitor='MyMetric', save_best_only=True)] train_history = model.fit([train_x], [train_y], batch_size=batch_size, epochs=epochs, validation_split=0.05, callbacks=best_model, verbose = 2) SO my model runs nut I get this warning: RuntimeWarning: Can save best model only with MyMetric