conv-neural-network

ValueError: Error when checking target: expected dense_2 to have 4 dimensions, but got array with shape (7942, 1)

不想你离开。 提交于 2020-01-02 09:26:33
问题 I have been using the following functional API for an image classification task using CNN: def create_model(X_train, X_test): visible = Input(shape=(X_train.shape[0], X_train.shape[1], 1)) conv1 = Conv2D(32, kernel_size=4, activation='relu')(visible) hidden1 = Dense(10, activation='relu')(pool2) output = Dense(1, activation='sigmoid')(hidden1) model = Model(inputs = visible, outputs = output) model.compile(loss='binary_crossentropy', optimizer='rmsprop', metrics=['accuracy']) return model X

How can I apply rotation to image in Keras without using model.fit_generator?

ぃ、小莉子 提交于 2020-01-02 08:56:20
问题 I am working on an image pixel classification problem using convolution neural nets. The size of my training images is 128x128x3 and the size of the label mask is 128x128 I do training in Keras as follows: Xtrain, Xvalid, ytrain, yvalid = train_test_split(images, masks,test_size=0.3, random_state=567) model.fit(Xtrain, ytrain, batch_size=32, epochs=20, verbose=1, shuffle=True, validation_data=(Xvalid, yvalid)) However, I want to apply a Random 2D rotation to Xtrain and ytrain which is also of

Residual learning in tensorflow

送分小仙女□ 提交于 2020-01-02 07:09:14
问题 I am attempting to replicate this image from a research paper. In the image, the orange arrow indicates a shortcut using residual learning and the layer outlined in red indicates a dilated convolution. In the code below, r5 is the result of the relu seen in the image. I have excluded the code between the relu and the dilation layer for simplicity. In tensorflow, how would I properly combine the result of the relu and dilated convolution to execute the residual shortcut? #relu layer r5 = tf.nn

Residual learning in tensorflow

老子叫甜甜 提交于 2020-01-02 07:09:11
问题 I am attempting to replicate this image from a research paper. In the image, the orange arrow indicates a shortcut using residual learning and the layer outlined in red indicates a dilated convolution. In the code below, r5 is the result of the relu seen in the image. I have excluded the code between the relu and the dilation layer for simplicity. In tensorflow, how would I properly combine the result of the relu and dilated convolution to execute the residual shortcut? #relu layer r5 = tf.nn

ValueError: Tensor Tensor(…) is not an element of this graph. When using global variable keras model

半城伤御伤魂 提交于 2020-01-02 05:21:09
问题 I'm running a web server using flask and the error comes up when I try to use vgg16, which is the global variable for keras' pre-trained VGG16 model. I have no idea why this error rises or whether it has anything to do with the Tensorflow backend. Here is my code: vgg16 = VGG16(weights='imagenet', include_top=True) def getVGG16Prediction(img_path): global vgg16 img = image.load_img(img_path, target_size=(224, 224)) x = image.img_to_array(img) x = np.expand_dims(x, axis=0) x = preprocess_input

Implement Causal CNN in Keras for multivariate time-series prediction

泪湿孤枕 提交于 2020-01-01 14:57:16
问题 This question is a followup to my previous question here: Multi-feature causal CNN - Keras implementation, however, there are numerous things that are unclear to me that I think it warrants a new question. The model in question here has been built according to the accepted answer in the post mentioned above. I am trying to apply a Causal CNN model on multivariate time-series data of 10 sequences with 5 features. lookback, features = 10, 5 What should filters and kernel be set to? What is the

How to classify continuous audio

天涯浪子 提交于 2020-01-01 10:58:07
问题 I have a audio data set and each of them has different length. There are some events in these audios, that I want to train and test but these events are placed randomly, plus the lengths are different, it is really hard to build a machine learning system with using that dataset. I thought fixing a default size of length and build a multilayer NN however, the length's of events are also different. Then I thought about using CNN, like it is used to recognise patterns or multiple humans on an

Multilabel image classification with sparse labels in TensorFlow?

孤街醉人 提交于 2020-01-01 10:16:33
问题 I want to perform a multilabel image classification task for n classes. I've got sparse label vectors for each image and each dimension of each label vector is currently encoded in this way: 1.0 ->Label true / Image belongs to this class -1.0 ->Label false / Image does not contain to this class. 0.0 ->missing value/label E.g.: V= {1.0,-1.0,1.0, 0.0} For this example V the model should learn, that the corresponding image should be classified in the first and third class. My problem is

Keras building a network for 9 dimensional feature vector

落爺英雄遲暮 提交于 2020-01-01 06:57:07
问题 I have the following simple data set. It consists of 9 features and it is a binary classification problem. An example of the feature vectors are show below. Each row has its corresponding 0,1 label. 30,82,1,2.73,172,117,2,2,655.94 30,174,1,5.8,256,189,3,2,587.28 98.99,84,2,0.84,577,367,3,2,1237.34 30,28,1,0.93,38,35,2,1,112.35 ... I know CNNs are used extensively for image classification, but I'm trying to apply it to the data set I've at hand. I'm trying to apply 5 filters each of size 2. I

Get weights from tensorflow model

岁酱吖の 提交于 2020-01-01 05:39:16
问题 Hello I would like to finetune VGG model from tensorflow. I have two questions. How to get the weights from network? The trainable_variables returns empty list for me. I used existing model from here: https://github.com/ry/tensorflow-vgg16 . I find the post about getting weights however this doesn't work for me because of import_graph_def. Get the value of some weights in a model trained by TensorFlow import tensorflow as tf import PIL.Image import numpy as np with open("../vgg16.tfmodel",