deep-learning

keras model not able to generalise

时光毁灭记忆、已成空白 提交于 2020-04-07 08:30:53
问题 Can you help me to find what wrong with my keras model, because it is overfitting since the second epoch. the following is the code: import random import pandas as pd import tensorflow as tf import numpy from sklearn.preprocessing import LabelEncoder from tensorflow.keras import backend as K import glob, os from sklearn.preprocessing import StandardScaler from sklearn.preprocessing import Normalizer class CustomSaver(tf.keras.callbacks.Callback): def on_epoch_end(self, epoch, logs={}): if(

Why does embedding vector multiplied by a constant in Transformer model?

本小妞迷上赌 提交于 2020-04-06 03:05:22
问题 I am learning to apply Transform model proposed by Attention Is All You Need from tensorflow official document Transformer model for language understanding. As section Positional encoding says: Since this model doesn't contain any recurrence or convolution, positional encoding is added to give the model some information about the relative position of the words in the sentence. The positional encoding vector is added to the embedding vector . My understanding is to add positional encoding

How to convert LSTM model to BiLSTM model in keras?

这一生的挚爱 提交于 2020-03-25 16:03:22
问题 I have the follwing two LSTM models where; model 1: first LSTM layer and then CNN layer model 2: first CNN layer and then LSTM layer Code of Model 1: model = Sequential() model.add(LSTM(100, return_sequences=True, input_shape=(25,3))) model.add(Conv1D(100, kernel_size=3, activation = 'relu')) model.add(GlobalMaxPooling1D()) model.add(Dense(50)) model.add(Dense(1, activation='sigmoid')) model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy']) Code of Model 2: model =

How to convert LSTM model to BiLSTM model in keras?

≡放荡痞女 提交于 2020-03-25 16:03:12
问题 I have the follwing two LSTM models where; model 1: first LSTM layer and then CNN layer model 2: first CNN layer and then LSTM layer Code of Model 1: model = Sequential() model.add(LSTM(100, return_sequences=True, input_shape=(25,3))) model.add(Conv1D(100, kernel_size=3, activation = 'relu')) model.add(GlobalMaxPooling1D()) model.add(Dense(50)) model.add(Dense(1, activation='sigmoid')) model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy']) Code of Model 2: model =

How to Merge two CNN models?

谁说我不能喝 提交于 2020-03-25 12:34:25
问题 I have 1D-CNN model and 2D-CNN model and want to merge them as mention in this paper , How can i merge them ? any help will appreciate , Thank you very much! from keras import Sequential, Model from keras.layers.core import Dense, Activation from keras.layers.convolutional import Conv2D , Conv1D from keras.layers import Conv2D, Conv1D,MaxPooling2D, Reshape, Concatenate, Dropout , MaxPooling1D from keras.layers.merge import concatenate from keras.layers import Dense, Input model_1D =

How to Merge two CNN models?

…衆ロ難τιáo~ 提交于 2020-03-25 12:33:42
问题 I have 1D-CNN model and 2D-CNN model and want to merge them as mention in this paper , How can i merge them ? any help will appreciate , Thank you very much! from keras import Sequential, Model from keras.layers.core import Dense, Activation from keras.layers.convolutional import Conv2D , Conv1D from keras.layers import Conv2D, Conv1D,MaxPooling2D, Reshape, Concatenate, Dropout , MaxPooling1D from keras.layers.merge import concatenate from keras.layers import Dense, Input model_1D =

keras save the model weights to one file

旧时模样 提交于 2020-03-23 23:20:00
问题 i have a keras model which save weights of each epoch how can i make to one file this is the line which saves the mode and i have 50 epoch i will get 50 weights which i want only 1 save all of them inside one file > model.save_weights('checkpoint_epoch_{}.hdf5'.format(k)) any idea what shall i do to save it in one file because i have to convert weights later to tensorflow model desiered weights checkpoint.h5 回答1: You don't need the weights in one file, you can save the whole model and use the

How to combine two LSTM layers with different input sizes in Keras?

纵然是瞬间 提交于 2020-03-23 10:24:10
问题 I have two types of input sequences where input1 contains 50 values and input2 contains 25 values. I tried to combine these two sequence types using a LSTM model in functional API. However since the length of my two input sequences are different, I am wondering whether what I am currently doing is the right way. My code is as follows: input1 = Input(shape=(50,1)) x1 = LSTM(100)(input1) input2 = Input(shape=(25,1)) x2 = LSTM(50)(input2) x = concatenate([x1,x2]) x = Dense(200)(x) output = Dense

Overfitting in Tensorflow Object detection API

自古美人都是妖i 提交于 2020-03-23 09:53:04
问题 I am training tensorflow object detection API model on the custom dataset i.e. License plate dataset. My goal is to deploy this model to the edge device using tensorflow lite so I can't use any RCNN family model . Because, I can't convert any RCNN family object detection model to tensorflow lite model (this is the limitation from tensorflow object detection API). I am using ssd_mobilenet_v2_coco model to train the custom dataset. Following is the code snippet of my config file: model { ssd {

“UserWarning: An input could not be retrieved. It could be because a worker has died. We do not have any information on the lost sample.”

眉间皱痕 提交于 2020-03-22 03:57:07
问题 While training model I got this warning "UserWarning: An input could not be retrieved. It could be because a worker has died.We do not have any information on the lost sample.)", after showing this warning, model starts training. What does this warning means? Is it something that will affect my training and I need to worry about? 回答1: This is just a user warning that will be usually thrown when you try to fetch the inputs,targets during training. This is because a timeout is set for the