keras-layer

expected input to have 4 dimensions, but got array with shape

允我心安 提交于 2020-02-27 07:11:56
问题 I have this error Error when checking input: expected input_13 to have 4 dimensions, but got array with shape (7, 100, 100) For the following code how should I reshape array to fit with 4-dimensions, I searched for it but didn't understand the previous solutions. Please ask if not clear its very common issue in convolution neural network. inputs=Input(shape=(100,100,1)) x=Conv2D(16,(3,3), padding='same')(inputs) x=Activation('relu')(x) x=Conv2D(8,(3,3))(x) x=Activation('relu')(x) x

expected input to have 4 dimensions, but got array with shape

泪湿孤枕 提交于 2020-02-27 07:11:26
问题 I have this error Error when checking input: expected input_13 to have 4 dimensions, but got array with shape (7, 100, 100) For the following code how should I reshape array to fit with 4-dimensions, I searched for it but didn't understand the previous solutions. Please ask if not clear its very common issue in convolution neural network. inputs=Input(shape=(100,100,1)) x=Conv2D(16,(3,3), padding='same')(inputs) x=Activation('relu')(x) x=Conv2D(8,(3,3))(x) x=Activation('relu')(x) x

Visualizing ConvNet filters using my own fine-tuned network resulting in a “NoneType” when running: K.gradients(loss, model.input)[0]

試著忘記壹切 提交于 2020-02-02 06:55:25
问题 I have a fine-tuned network that I created which uses vgg16 as it's base. I am following section 5.4.2 Visualizing CovNet Filters in Deep Learning With Python (which is very similar to the guide on the Keras blog to visualize convnet filters here). The guide simply uses the vgg16 network. My fine tuned model uses the vgg16 model as the base, for example: model.summary() Layer (type) Output Shape Param # ======================================================================= vgg16 (Model)

Visualizing ConvNet filters using my own fine-tuned network resulting in a “NoneType” when running: K.gradients(loss, model.input)[0]

这一生的挚爱 提交于 2020-02-02 06:55:13
问题 I have a fine-tuned network that I created which uses vgg16 as it's base. I am following section 5.4.2 Visualizing CovNet Filters in Deep Learning With Python (which is very similar to the guide on the Keras blog to visualize convnet filters here). The guide simply uses the vgg16 network. My fine tuned model uses the vgg16 model as the base, for example: model.summary() Layer (type) Output Shape Param # ======================================================================= vgg16 (Model)

Visualizing ConvNet filters using my own fine-tuned network resulting in a “NoneType” when running: K.gradients(loss, model.input)[0]

孤街醉人 提交于 2020-02-02 06:54:31
问题 I have a fine-tuned network that I created which uses vgg16 as it's base. I am following section 5.4.2 Visualizing CovNet Filters in Deep Learning With Python (which is very similar to the guide on the Keras blog to visualize convnet filters here). The guide simply uses the vgg16 network. My fine tuned model uses the vgg16 model as the base, for example: model.summary() Layer (type) Output Shape Param # ======================================================================= vgg16 (Model)

Error when checking model target: expected dense_39 to have 3 dimensions, but got array with shape (940, 1)

China☆狼群 提交于 2020-01-24 23:59:12
问题 I'm trying to train this Convolutional Neural Network but can't figure out what the issue is with my last layer. model = Sequential() model.add(Conv1D(50, kernel_size=(1), activation='relu', input_dim=50)) model.add(Dense(32)) model.add(Dense(1)) model.summary() model.compile(loss=keras.losses.mean_squared_error, optimizer=keras.optimizers.adam()) model.fit(X_train, y_train, batch_size=940, epochs=10, verbose=1, validation_data=(X_test, y_test)) Model: ________________________________________

Sentence embedding in keras

时光怂恿深爱的人放手 提交于 2020-01-23 03:59:25
问题 I am trying a simple document classification using sentence embeddings in keras. I know how to feed word vectors to a network, but I have problems using sentence embeddings. In my case, I have a simple representation of sentences (adding the word vectors along the axis, for example np.sum(sequences, axis=0) ). My question is, what should I replace the Embedding layer with in the code below to feed sentence embeddings instead? model = Sequential() model.add(Embedding(len(embedding_weights),

Memory leak when running universal-sentence-encoder-large itterating on dataframe

人走茶凉 提交于 2020-01-16 09:10:12
问题 I have 140K sentences I want to get embeddings for. I am using TF_HUB Universal Sentence Encoder and am iterating over the sentences(I know it's not the best way but when I try to feed over 500 sentences into the model it crashes). My Environment is: Ubuntu 18.04 Python 3.7.4 TF 1.14 Ram: 16gb processor: i-5 my code is: version 1 I iterate inside the tf.session context manager embed = hub.Module("https://tfhub.dev/google/universal-sentence-encoder-large/3") df = pandas_repository.get

Keras - Fusion of a Dense Layer with a Convolution2D Layer

浪尽此生 提交于 2020-01-12 08:26:35
问题 I want to make a custom layer which is supposed to fuse the output of a Dense Layer with a Convolution2D Layer. The Idea came from this paper and here's the network: the fusion layer tries to fuse the Convolution2D tensor ( 256x28x28 ) with the Dense tensor ( 256 ). here's the equation for it: y_global => Dense layer output with shape 256 y_mid => Convolution2D layer output with shape 256x28x28 Here's the description of the paper about the Fusion process: I ended up making a new custom layer

Keras - Fusion of a Dense Layer with a Convolution2D Layer

只愿长相守 提交于 2020-01-12 08:26:31
问题 I want to make a custom layer which is supposed to fuse the output of a Dense Layer with a Convolution2D Layer. The Idea came from this paper and here's the network: the fusion layer tries to fuse the Convolution2D tensor ( 256x28x28 ) with the Dense tensor ( 256 ). here's the equation for it: y_global => Dense layer output with shape 256 y_mid => Convolution2D layer output with shape 256x28x28 Here's the description of the paper about the Fusion process: I ended up making a new custom layer