conv-neural-network

Error when checking target: expected softmax_1 to have shape (1,) but got array with shape (2,)', Keras

て烟熏妆下的殇ゞ 提交于 2019-12-11 15:45:03
问题 I am using Keras for building Conv Net for the first time. My layers are as follows: layers = [ Conv2D(8,kernel_size=(4,4),padding='same',input_shape=( 200, 180,3),kernel_initializer="glorot_normal",data_format="channels_first"), Activation("relu"), MaxPooling2D(pool_size=(8,8),padding='same',data_format='channels_first'), Conv2D(16,(2,2),padding='same',kernel_initializer="glorot_normal"), Activation("relu"), MaxPooling2D(pool_size=(4,4),padding='same',data_format='channels_first'), Conv2D(4,

ResNet for Binary classification- Just 2 values of cross-validation accuracy

随声附和 提交于 2019-12-11 15:32:28
问题 I am new to python and Keras. I am trying to do a binary classification using transfer learning from ResNet. My dataset is very small but I am using image augmentation. My cross-validation accuracy is just either of 2 values 0.3442 and 0.6558 for all images. Can anyone tell me why this happens? Also when I predict (0 or 1), it labels all images as one class(0). Here is my code: from keras.preprocessing.image import ImageDataGenerator, load_img from keras.models import Sequential,Model,load

The Accuracy Metric Purpose

时光毁灭记忆、已成空白 提交于 2019-12-11 15:28:32
问题 I am using Keras to build a CNN and I have come to a misunderstanding about what the Accuracy metric does exactly. I have done some research and it appears that it returns the Accuracy of the model. Where is this information stored exactly? Does this metric effect the epoch results? I cannot find any resources that actually describe in depth what the Accuracy metric does. How are my results affected by using this metric? model.compile( loss="sparse_categorical_crossentropy", optimizer='adam',

Detecting pedestrian using CaffeNet model at moderate framerate

吃可爱长大的小学妹 提交于 2019-12-11 12:53:41
问题 I train the CaffeNet (more precisely Cifar10 model for two classes classification) model. Now the model is ready for detection. For the model testing with a single image, I use test_predict_imagenet.cpp . I haven't tested how fast the code can run for 640 x 480 image. My target is I like to have 5~10 frame/sec is just nice for offline detection. I understand that I need to implement multi-size detection (i.e. something like we do in face detection, original image size is re-sized for

How do I modify this PyTorch convolutional neural network to accept a 64 x 64 image and properly output predictions?

廉价感情. 提交于 2019-12-11 12:47:11
问题 I took this convolutional neural network (CNN) from here. It accepts 32 x 32 images and defaults to 10 classes. However, I have 64 x 64 images with 500 classes. When I pass in 64 x 64 images (batch size held constant at 32), I get the following error. ValueError: Expected input batch_size (128) to match target batch_size (32). The stack trace starts at the line loss = loss_fn(outputs, labels) . The outputs.shape is [128, 500] and the labels.shape is [32] . The code is listed here for

Cython memoryview transpose: Typeerror

*爱你&永不变心* 提交于 2019-12-11 12:17:33
问题 I'm trying to develop a small Convolutional Neural Network framework with python. The code for the convolutional node already works (slowly) and I would like to speed it up. The hotspots are the loops where the convolutional filter is moved across the image. I chose to use cython to speed up those loops. The obvious small annotations, cdef for all local variables and removing boundscheck, shaved hardly 10% off of my runtime. That seemed strange to me, based on what I read online, cython

How to re-initialize layer weights of an existing model in Keras?

南笙酒味 提交于 2019-12-11 12:13:33
问题 The actual problem is generating random layer weights for an existing (already built) model in Keras. There are some solutions using Numpy [2] but it is not good to choice that solutions. Because, in Keras, there are special initializers using different distributions for each layer type. When Numpy is used instead of the initializers, the generated weights have different distribution then its original. Let's give an example: Second layer of my model is a convolutional (1D) layer and its

Can not convert a ndarray into a Tensor or Operation error in TensorFlow model

房东的猫 提交于 2019-12-11 09:45:45
问题 I am implementing a Wasserstein DCGAN in TensorFlow. The error occurs when this line is run : train_image = sess.run(image_batch) . The handling of this exception throws another exception Fetch argument array([[[0, 0, 0, ..., 0, 0, 0], [0, 0, 0, ..., 0, 0, 0], [0, 0, 0, ..., 0, 0, 0], ..., [0, 0, 0, ..., 0, 0, 0], [0, 0, 0, ..., 0, 0, 0], [0, 0, 0, ..., 0, 0, 0]], [[0, 0, 0, ..., 0, 0, 0], [0, 0, 0, ..., 0, 0, 0], [0, 0, 0, ..., 0, 0, 0], ..., [0, 0, 0, ..., 0, 0, 0], [0, 0, 0, ..., 0, 0, 0],

Dimension error when using predict method on an image in a CNN model

醉酒当歌 提交于 2019-12-11 09:07:44
问题 I am trying to predict on a single image using Keras (2.2.4) and TensorFlow (1.9.0) as the backend: def enigne(data): img=data image_shape=img.shape num_train_samples = 4206 num_val_samples = 916 train_batch_size = 10 val_batch_size = 10 IMAGE_SIZE = 64 IMAGE_CHANNELS = 3 kernel_size = (3, 3) pool_size = (2, 2) first_filters = 32 second_filters = 128 image_resize=cv.resize(img,(64,64)) # Loading the model model = Sequential() model.add(Conv2D(first_filters, kernel_size, activation='relu',

defining a siamese network in tensorflow

[亡魂溺海] 提交于 2019-12-11 08:04:19
问题 I know this question has been asked before, however I've a specific question which has not been answered before. I am trying to define a Siamese network in Tensorflow as follows: def conv(self, x, num_out_maps, ksize, stride, activation_fn=tf.nn.relu): padding_length = np.floor((ksize-1)/2).astype(np.int32) padded_input = tf.pad(x, [[0, 0], [padding_length, padding_length], [padding_length, padding_length], [0, 0]]) return slim.conv2d(padded_input, num_out_maps, ksize, stride, padding='VALID'