keras

Export gensim doc2vec embeddings into separate file to use with keras Embedding layer later

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-10 07:08:07
问题 I am a bit new to gensim and right now I am trying to solve the problem which involves using the doc2vec embeddings in keras. I wasn't able to find existing implementation of doc2vec in keras - as far as I see in all examples I found so far everyone just uses the gensim to get the document embeddings. Once I trained my doc2vec model in gensim I need to export embeddings weights from genim into keras somehow and it is not really clear on how to do that. I see that model.syn0 Supposedly gives

Export gensim doc2vec embeddings into separate file to use with keras Embedding layer later

隐身守侯 提交于 2021-02-10 07:05:49
问题 I am a bit new to gensim and right now I am trying to solve the problem which involves using the doc2vec embeddings in keras. I wasn't able to find existing implementation of doc2vec in keras - as far as I see in all examples I found so far everyone just uses the gensim to get the document embeddings. Once I trained my doc2vec model in gensim I need to export embeddings weights from genim into keras somehow and it is not really clear on how to do that. I see that model.syn0 Supposedly gives

Training a unet model , but model is not learning

好久不见. 提交于 2021-02-10 07:00:22
问题 I am trying to train a segmentation model, But loss saturates at 0.3370 , i am really not sure what to do, can someone please help This is the model def unet(input_shape=(128, 128, 128), optimizer=Adam, initial_learning_rate=5e-4, loss_function=weighted_dice_coefficient_loss): inputs = Input(shape=input_shape) conv1 = UnetConv3D(inputs, 32, is_batchnorm=False, name='conv1') pool1 = MaxPooling3D(pool_size=(2, 2,2 ))(conv1) conv2 = UnetConv3D(pool1, 64, is_batchnorm=False, name='conv2') pool2 =

Training a unet model , but model is not learning

荒凉一梦 提交于 2021-02-10 07:00:07
问题 I am trying to train a segmentation model, But loss saturates at 0.3370 , i am really not sure what to do, can someone please help This is the model def unet(input_shape=(128, 128, 128), optimizer=Adam, initial_learning_rate=5e-4, loss_function=weighted_dice_coefficient_loss): inputs = Input(shape=input_shape) conv1 = UnetConv3D(inputs, 32, is_batchnorm=False, name='conv1') pool1 = MaxPooling3D(pool_size=(2, 2,2 ))(conv1) conv2 = UnetConv3D(pool1, 64, is_batchnorm=False, name='conv2') pool2 =

How to use part of inputs for training but rest for loss function in Keras

人盡茶涼 提交于 2021-02-10 06:28:19
问题 I am new to Keras and trying to implement a neural network machine learning model. The input tensor looks like (X1, X2) and outputs (Y). Note X1 and X2 are correlated. In the model, only X1 will be used for training, but both X1 and X2 will be passed to the loss function that is a function of X1, X2, y_pred and y_true. Below is a pseudocode for loss function. def customLossFunctionWrapper(input_tensor): def LossFunction(y_pred, y_true): loss_value = f(X1, X2, y_pred, y_true) return loss_value

How to use part of inputs for training but rest for loss function in Keras

痴心易碎 提交于 2021-02-10 06:28:11
问题 I am new to Keras and trying to implement a neural network machine learning model. The input tensor looks like (X1, X2) and outputs (Y). Note X1 and X2 are correlated. In the model, only X1 will be used for training, but both X1 and X2 will be passed to the loss function that is a function of X1, X2, y_pred and y_true. Below is a pseudocode for loss function. def customLossFunctionWrapper(input_tensor): def LossFunction(y_pred, y_true): loss_value = f(X1, X2, y_pred, y_true) return loss_value

How to use part of inputs for training but rest for loss function in Keras

别等时光非礼了梦想. 提交于 2021-02-10 06:28:06
问题 I am new to Keras and trying to implement a neural network machine learning model. The input tensor looks like (X1, X2) and outputs (Y). Note X1 and X2 are correlated. In the model, only X1 will be used for training, but both X1 and X2 will be passed to the loss function that is a function of X1, X2, y_pred and y_true. Below is a pseudocode for loss function. def customLossFunctionWrapper(input_tensor): def LossFunction(y_pred, y_true): loss_value = f(X1, X2, y_pred, y_true) return loss_value

Visualizing the Gradients as heat map in Tensorflow 2

隐身守侯 提交于 2021-02-10 05:35:49
问题 I am working on a task to generate heatmap by guided backpropagation. I have overridden the original Relu and obtained the gradient for each parameter. However, I am not sure what should I do next. Your assistance is appreciated! Thank you! Here is my code: I first use @tf.RegisterGradient("GuidedRelu") like: def _GuidedReluGrad(op, grad): gate_f = tf.cast(op.outputs[0] > 0, "float32") gate_R = tf.cast(grad > 0, "float32") return gate_f * gate_R * grad Then, I obtained grads by: with g

Output Probability score with keras using model.predict()

别等时光非礼了梦想. 提交于 2021-02-10 04:59:46
问题 I have a cnn model for image classification which uses a sigmoid activation function as its last layer from keras import layers from keras import models model = models.Sequential() model.add(layers.Conv2D(32, (3, 3), activation='relu', input_shape=(1500, 1500, 3))) .......... model.add(layers.Dense(1, activation='sigmoid')) The images belong to two classes. When I use the model.predict() on an image I get a 0 or a 1. However I want to get a probability score like 0.656 for example when I use

How to use model input in loss function?

梦想的初衷 提交于 2021-02-10 03:28:07
问题 I am trying to use a custom loss-function which depends on some arguments that the model does not have. The model has two inputs ( mel_specs and pred_inp ) and expects a labels tensor for training: def to_keras_example(example): # Preparing inputs return (mel_specs, pred_inp), labels # Is a tf.train.Dataset for model.fit(train_data, ...) train_data = load_dataset(fp, 'train).map(to_keras_example).repeat() In my loss function I need to calculate the lengths of mel_specs and pred_inp . This