transfer-learning

Pretraining a language model on a small custom corpus

筅森魡賤 提交于 2020-07-21 07:55:05
问题 I was curious if it is possible to use transfer learning in text generation, and re-train/pre-train it on a specific kind of text. For example, having a pre-trained BERT model and a small corpus of medical (or any "type") text, make a language model that is able to generate medical text. The assumption is that you do not have a huge amount of "medical texts" and that is why you have to use transfer learning. Putting it as a pipeline, I would describe this as: Using a pre-trained BERT

Error “IndexError: How to predict input image using trained model in Keras?

孤者浪人 提交于 2020-05-17 07:05:44
问题 I trained a model to classify images from 9 classes and saved it using model.save(). Here is the code I used: from keras.applications.resnet50 import ResNet50, preprocess_input from keras.layers import Dense, Dropout from keras.models import Model from keras.optimizers import Adam, SGD from keras.preprocessing.image import ImageDataGenerator, image from keras.callbacks import EarlyStopping, ModelCheckpoint from sklearn.metrics import confusion_matrix, classification_report, accuracy_score

Error “IndexError: How to predict input image using trained model in Keras?

末鹿安然 提交于 2020-05-17 07:05:07
问题 I trained a model to classify images from 9 classes and saved it using model.save(). Here is the code I used: from keras.applications.resnet50 import ResNet50, preprocess_input from keras.layers import Dense, Dropout from keras.models import Model from keras.optimizers import Adam, SGD from keras.preprocessing.image import ImageDataGenerator, image from keras.callbacks import EarlyStopping, ModelCheckpoint from sklearn.metrics import confusion_matrix, classification_report, accuracy_score

The added layer must be an instance of class Layer. Found: <tensorflow.python.keras.engine.input_layer.InputLayer>

霸气de小男生 提交于 2020-05-10 07:36:29
问题 I am new to machine learning. I was following this tutorial on fine tuning VGG16 models. The model loaded fine with this code: vgg_model = tensorflow.keras.applications.vgg16.VGG16() but gets this ERROR: TypeError: The added layer must be an instance of class Layer. Found: <tensorflow.python.keras.engine.input_layer.InputLayer object at 0x000001FA104CBB70> When running this code: model = Sequential() for layer in vgg_model.layers[:-1]: model.add(layer) Dependencies: Keras 2.2.3 Tensorflow 1

KerasLayer vs tf.keras.applications performances

て烟熏妆下的殇ゞ 提交于 2020-02-05 03:36:41
问题 I've trained some networks with ResNetV2 50 ( https://tfhub.dev/google/imagenet/resnet_v2_50/feature_vector/4 ) and it work very well for my datasets. Then I tried tf.keras.applications.ResNet50 and accuracy is very lower than the other. Here two models: The first (with hub) base_model = hub.KerasLayer('https://tfhub.dev/google/imagenet/resnet_v2_50/feature_vector/4', input_shape=(IMAGE_H, IMAGE_W, 3)) base_model.trainable = False model = tf.keras.Sequential([ base_model , Dense(num_classes,

Converting keras.applications.resnet50 to a Sequential gives error

青春壹個敷衍的年華 提交于 2020-01-16 18:01:12
问题 I want to convert pretrained ResNet50 model from keras.application to a Sequential model but it gives input_shape error. Input 0 is incompatible with layer res2a_branch1: expected axis -1 of input shape to have value 64 but got shape (None, 25, 25, 256) I read this https://github.com/keras-team/keras/issues/9721 and as I understand the reason of error is skip_connections. Is there a way to convert it to a Sequential or how can I add my custom model to end of this ResNet Model. This is the

How to decode vggish audioset embeddings from tfrecord?

谁说胖子不能爱 提交于 2019-12-23 04:41:27
问题 I am trying to use the 128 byte embeddings produced by the pre-trained base of the VGGish model for transfer learning on audio data. Using python vggish_inference_demo.py --wav_file ... to encode my training data to a tfrecord worked fine, but now I want to use this as an input to another model (e.g. a neural network I create with keras or something else). Using some similar questions and the documentation, I go this far with the first embedding record of one file: tfrecords_filename =

Cannot predict the label for a single image with VGG19 in Keras

北城以北 提交于 2019-12-17 20:42:09
问题 I'm using transfer learning method to use per-trained VGG19 model in Keras according to [this tutorial](https://towardsdatascience.com/keras-transfer-learning-for-beginners-6c9b8b7143e ). It shows how to train the model but NOT how to prepare test images for the predictions. In the comments section it says: Get an image, preprocess the image using the same preprocess_image function, and call model.predict(image) . This will give you the prediction of the model on that image. Using argmax

Strange behaviour of the loss function in keras model, with pretrained convolutional base

末鹿安然 提交于 2019-12-17 14:01:35
问题 I'm trying to create a model in Keras to make numerical predictions from the pictures. My model has densenet121 convolutional base, with couple of additional layers on top. All layers except for the two last ones are set to layer.trainable = False . My loss is mean squared error, since it's a regression task. During training I get loss: ~3 , while evaluation on the very same batch of the data gives loss: ~30 : model.fit(x=dat[0],y=dat[1],batch_size=32) Epoch 1/1 32/32 [=======================

Data Augmentation hurts accuracy Keras

北战南征 提交于 2019-12-13 03:57:55
问题 I'm trying to adapt Deep Learning with Python section 5.3 Feature extraction with Data Augmentation to a 3-class problem with resnet50 (imagenet weights). Full code at https://github.com/morenoh149/plantdisease from keras import models from keras import layers from keras.applications.resnet50 import ResNet50 from keras import optimizers from keras.preprocessing.image import ImageDataGenerator input_shape = (224, 224, 3) target_size = (224, 224) batch_size = 20 conv_base = ResNet50(weights=