keras

Deep Learning with Python code no longer working. “TypeError: An op outside of the function building code is being passed a ”Graph“ tensor.”

别说谁变了你拦得住时间么 提交于 2021-01-28 05:11:08
问题 I'm implementing a Tensorflow Variational Autoencoder, copying the code exactly from the book "Deep Learning with Python". Up until a few days ago, the code was working perfectly but as of yesterday it has stopped working (I have not changed the code). The code is for a generative model which can replicate images from the MNIST dataset. The specific error message is below: TypeError: An op outside of the function building code is being passed a "Graph" tensor. It is possible to have Graph

Is there any way to access layers in tensorflow_hub.KerasLayer object?

依然范特西╮ 提交于 2021-01-28 03:21:13
问题 I am trying to use a pre-trained model from tensorflow hub into my object detection model. I wrapped a model from hub as a KerasLayer object following the official instruction. Then I realized that I cannot access the layers in this pre-trained model . But I need to use outputs from some specific layers to build my model. Is there any way to access layers in tensorflow_hub.KerasLayer object? 回答1: For one to be able to do that easily, the creator of the pretrained model would have needed to

ValueError: Error when checking target: expected dense_1 to have 2 dimensions, but got array with shape (68, 50, 50, 50, 1)

坚强是说给别人听的谎言 提交于 2021-01-28 03:12:05
问题 I'm trying to build a convolutional network that will work on a 3D voxel grid. I try to add a fully connected layer but get an error: ValueError: Error when checking target: expected dense_1 to have 2 dimensions, but got array with shape (68, 50, 50, 50, 1) How can this be happening when I have a flatten layer first? Shouldn't my input to the dense layer at that point be, well, flat? x, y = load_data(directory) x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.25, random

Branched output Keras

烂漫一生 提交于 2021-01-28 01:18:22
问题 My model is such that it branches into 2 output layers as follows: Input -> L1 -> L2 -> L3 -> out1 Input -> L1 -> L2 -> L3 -> out2 I am using it this way because I want out1 and out2 to have 2 different activation functions. Therefore, I have created a model: model = Model(inputs=[input_layer], outputs=[out1, out2]) I am compiling it using: model.compile(Adam(lr=1e-2), loss=[loss_fn1, loss_fn2], metrics=[accuracy]) loss functions are defined this way: def loss_fn1(y_true, y_pred): #send

Validation Loss Much Higher Than Training Loss

亡梦爱人 提交于 2021-01-27 23:36:54
问题 I'm very new to deep learning models, and trying to train a multiple time series model using LSTM with Keras Sequential. There are 25 observations per year for 50 years = 1250 samples, so not sure if this is even possible to use LSTM for such small data. However, I have thousands of feature variables, not including time lags. I'm trying to predict a sequence of the next 25 time steps of data. The data is normalized between 0 and 1. My problem is that, despite trying many obvious adjustments,

y parameter in Keras fit and evaluate functions

徘徊边缘 提交于 2021-01-27 22:57:27
问题 The Keras documentation says that the y parameter in fit and evaluate functions can be set to None, which actually is the default. (I shorten the function definitions below to save some space.) fit(self, x=None, **y=None**, ...) evaluate(self, x=None, **y=None**, ...) And the documentation motivates the value None as following: "y can be None (default) if feeding from framework-native tensors (e.g. TensorFlow data tensors)." This does not really tell me that much. Could anyone explain what

Converting Keras (Tensorflow) convolutional neural networks to PyTorch convolutional networks?

被刻印的时光 ゝ 提交于 2021-01-27 21:07:04
问题 Keras and PyTorch use different arguments for padding: Keras requires a string to be input, while PyTorch works with numbers. What is the difference, and how can one be translated into another (what code gets the equivalent result in either framework)? PyTorch also takes the args in_channels, out_chanels while keras only takes an argument called filters. What does 'filters' mean? 回答1: Regarding padding, Keras => 'valid' - no padding; 'same' - input is padded so that the output shape is same

Average layer in multi input deep learning

不想你离开。 提交于 2021-01-27 20:35:51
问题 I am working to create a multi-input Convolutional Neural Network (CNN) model in Keras for Images Classification that takes two images and gives one output which is the class of the two images. I have two datasets: type1 and type2, and each dataset contains the same classes. The model should take one image from Type1 dataset and one image from Type2 dataset and then classify these images to one class (ClassA or ClassB or------). I want to create a model that predict the two images and then

keras compute_output_shape not working for Custom layer

北战南征 提交于 2021-01-27 19:40:35
问题 I customized a layer, merged the batch_size and the first dimension, the other dimensions remained unchanged, but compute_output_shape seemed to have no effect, resulting in the subsequent layer could not get accurate shape information, resulting in an error. How do I make compute_output_shape work? import keras from keras import backend as K class BatchMergeReshape(keras.layers.Layer): def __init__(self, **kwargs): super(BatchMergeReshape, self).__init__(**kwargs) def build(self, input_shape

AttributeError: 'NoneType' object has no attribute '_inbound_nodes' Keras

给你一囗甜甜゛ 提交于 2021-01-27 18:51:19
问题 from Config import Config from FaceDetection.MTCNNDetect import MTCNNDetect import cv2 import tensorflow as tf import keras from keras import backend as K from keras.layers import Input, Lambda, Dense, Dropout, Convolution2D, MaxPooling2D, Flatten, Concatenate, concatenate from keras.models import Model face_detect = MTCNNDetect(model_path=Config.MTCNN_MODEL) from FaceRecognition.TensorflowGraph import FaceRecGraph from src.FaceAlignment import AlignCustom from FaceRecognition.FaceFeature