conv-neural-network

Changing the input data layer during training in Caffe

让人想犯罪 __ 提交于 2019-12-06 13:50:05
Is it possible to change the input source of ImageData layer or a MemoryData layer on the fly? I am trying to shuffle the data every epoch but I have both image and some other non-image features that I want to concatenate at a later stage in the network. I could not find a reliable way to shuffle both the image and my other data in a way that preserves the alignment of the two. So, I am thinking of re-generating the imagelist.txt as well as nonimage data (in Memory) every epoch and attach the new file to the ImageData layer and initialize MemoryDataLayer with the new data. How can I make sure

Keras Functional model giving high validation accuracy but incorrect prediction

我与影子孤独终老i 提交于 2019-12-06 13:26:49
I am trying to do transfer learning for VGG16 architecture with 'ImageNet' pretrained weights on PASCAL VOC 2012 dataset. PASCAL VOC is a multi label image dataset with 20 classes, and so I have modified the inbuilt VGG16 model like this: def VGG16_modified(): base_model = vgg16.VGG16(include_top=True,weights='imagenet',input_shape=(224,224,3)) print(base_model.summary()) x = base_model.get_layer('block5_pool').output x = (GlobalAveragePooling2D())(x) predictions = Dense(20,activation='sigmoid')(x) final_model = Model(input = base_model.input, output = predictions) print(final_model.summary())

Caffe accuracy bigger than 100%

纵饮孤独 提交于 2019-12-06 11:52:19
I'm building one but, and when I use the custom train function provided on lenet example with a batch size bigger than 110 my accuracy gets bigger than 1 (100%). If I use batch size 32, I get 30 percent of accuracy. Batch size equal 64 my net accuracy is 64. And batch size equal to 128, the accuracy is 1.2. My images are 32x32. Train dataset: 56 images of Neutral faces. 60 images of Surprise faces. Test dataset: 15 images of Neutral faces. 15 images of Surprise faces. This is my code: def train(solver): niter = 200 test_interval = 25 train_loss = zeros(niter) test_acc = zeros(int(np.ceil(niter

Keras TimeDistributed Conv1D Error

末鹿安然 提交于 2019-12-06 10:36:28
This is my code: cnn_input = Input(shape=(cnn_max_length,)) emb_output = Embedding(num_chars + 1, output_dim=32, input_length=cnn_max_length, trainable=True)(cnn_input) output = TimeDistributed(Convolution1D(filters=128, kernel_size=4, activation='relu'))(emb_output) I want to train a character-level CNN sequence labeler and I keep receiving this error: Traceback (most recent call last): File "word_lstm_char_cnn.py", line 24, in <module> output = kl.TimeDistributed(kl.Convolution1D(filters=128, kernel_size=4, activation='relu'))(emb_output) File "/home/user/anaconda3/envs/thesisenv/lib/python3

the number of neurons in AlexNet

↘锁芯ラ 提交于 2019-12-06 10:29:10
In AlexNet ,the image data is 3*224*224 . The first convolutional layer filters the image with 96 kernels of size 11*11*3 with a stride of 4 piexels. I have doubt with the first layer's output neurons count. In my opinion,the input is 224*224*3=150528 ,then the output should be 55*55*96=290400 But in the paper,they described the output is 253440 I don't know how to calculate the number of this layer's neurons. Is there someone could help me?Thank you! It seems like the input size is 227x227, without padding. I also think that what they mention in the paper is a mistake. Have look at this link.

Counting the number of vehicles from an image with machine learning

此生再无相见时 提交于 2019-12-06 10:06:26
问题 I am new to machine learning. I got a task to find the total number of vehicles from an image using machine learning concept. I am using neural network. My image of worst case is given here. Traffic Image I need to find the total number of cars from this image. My idea is to cut this big image into small patches of image and train the network to count the vehicles from the small patches. Each patch will be having count less than 5. Then in the processing of new image, I could make use of a

How to do multi-class image classification in keras?

人盡茶涼 提交于 2019-12-06 09:55:13
Here is what I did. I got the code for dog/cat image classification and I compiled and ran and got 80% accuracy. I added one more class (aeroplane) folder to the train and validation folder. Made changes in the following codes model.compile(loss='categorical_crossentropy', optimizer='rmsprop', metrics=['accuracy']) train_generator = train_datagen.flow_from_directory( train_data_dir, target_size=(img_width, img_height), batch_size=batch_size, class_mode='categorical') validation_generator = test_datagen.flow_from_directory( validation_data_dir, target_size=(img_width, img_height), batch_size

How to use tensorflow tf.metrics.mean_iou?

北城余情 提交于 2019-12-06 08:57:50
问题 I am trying to use the inbuilt mean_iou function of tensorflow to compute the IoU score for semantic segmentation. My code is: #y_mask.shape == [batch_size, h * w, n_classes] #y_mask.shape == [batch_size, h * w, n_classes] iou = tf.metrics.mean_iou(tf.argmax(y_mask,2), tf.argmax(mask_,2), n_classes) However I am getting the following error trace: tensorflow.python.framework.errors_impl.FailedPreconditionError: Attempting to use uninitialized value mean_iou/total_confusion _matrix [[Node: mean

How do I turn a Pytorch Dataloader into a numpy array to display image data with matplotlib?

混江龙づ霸主 提交于 2019-12-06 08:50:41
问题 I am new to Pytorch. I have been trying to learn how to view my input images before I begin training on my CNN. I am having a very hard time changing the images into a form that can be used with matplotlib. So far I have tried this: from multiprocessing import freeze_support import torch from torch import nn import torchvision from torch.autograd import Variable from torch.utils.data import DataLoader, Sampler from torchvision import datasets from torchvision.transforms import transforms from

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

有些话、适合烂在心里 提交于 2019-12-06 08:12:19
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 size 128x128x3 and 128x128 respectively. More specifically, I want to apply this rotation for every