conv-neural-network

Why does different batch-sizes give different accuracy in Keras?

别说谁变了你拦得住时间么 提交于 2019-12-08 15:21:19
问题 I was using Keras' CNN to classify MNIST dataset. I found that using different batch-sizes gave different accuracies. Why is it so? Using Batch-size 1000 (Acc = 0.97600) Using Batch-size 10 (Acc = 0.97599) Although, the difference is very small, why is there even a difference? EDIT - I have found that the difference is only because of precision issues and they are in fact equal. 回答1: That is because of the Mini-batch gradient descent effect during training process. You can find good

Two parallel conv2d layers (keras)

一世执手 提交于 2019-12-08 10:56:10
问题 I want two build a neural network that takes two separate matrices with same dimensions (for example grey-scale images) as input, and outputs a value between -1 and 1 (probably tanh). I would like to build the network so that there are two seperate convolutional layers as inputs. Each one takes one matrix(or image). An then that these one are combined in a following layer. So i want it to look something like that: My first question is can i do this in keras (or if not in tensorflow)? The

Keras cnn model output shape doesn't match model summary

时光怂恿深爱的人放手 提交于 2019-12-08 10:32:38
问题 I am trying to use the convolution part of ResNet50() model, as this: #generate batches def get_batches(dirname, gen=image.ImageDataGenerator(), shuffle=True, batch_size=4, class_mode='categorical', target_size=(224,224)): return gen.flow_from_directory(dirname, target_size=target_size, class_mode=class_mode, shuffle=shuffle, batch_size=batch_size) trn_batches = get_batches("path_to_dirctory", shuffle=False,batch_size=4) #create model rn_mean = np.array([123.68, 116.779, 103.939], dtype=np

Keras fit freezes at the end of the first epoch

Deadly 提交于 2019-12-08 09:16:42
问题 I am currently experimenting with fine tuning the VGG16 network using Keras. I started tweaking a little bit with the cats and dogs dataset. However, with the current configuration the training seems to block on the first epoch from keras import applications from keras.preprocessing.image import ImageDataGenerator from keras import optimizers from keras.models import Sequential, Model from keras.layers import Dropout, Flatten, Dense img_width, img_height = 224, 224 train_data_dir = 'data

Understanding the output shape of conv2d layer in keras

感情迁移 提交于 2019-12-08 07:54:47
问题 I do not understand why the channel dimension is not included in the output dimension of a conv2D layer in Keras. I have the following model def create_model(): image = Input(shape=(128,128,3)) x = Conv2D(24, kernel_size=(8,8), strides=(2,2), activation='relu', name='conv_1')(image) x = Conv2D(24, kernel_size=(8,8), strides=(2,2), activation='relu', name='conv_2')(x) x = Conv2D(24, kernel_size=(8,8), strides=(2,2), activation='relu', name='conv_3')(x) flatten = Flatten(name='flatten')(x)

How to apply CNN to Short-time Fourier Transform?

安稳与你 提交于 2019-12-08 07:52:45
问题 So I have a code which returns a Short-Time Fourier Transform spectrum of a .wav file. I want to be able to take, say a millisecond of the spectrum, and train a CNN on it. I'm not quite sure how I would implement that. I know how to format the image data to feed into the CNN, and how to train the network, but I'm lost on how to take the FFT-data and divide it into small time-frames. The FFT Code(Sorry for ultra long code): rate, audio = wavfile.read('scale_a_lydian.wav') audio = np.mean(audio

Trying to understand CNNs for NLP tutorial using Tensorflow

走远了吗. 提交于 2019-12-08 07:07:16
问题 I am following this tutorial in order to understand CNNs in NLP. There are a few things which I don't understand despite having the code in front of me. I hope somebody can clear a few things up here. The first rather minor thing is the sequence_length parameter of the TextCNN object. In the example on github this is just 56 which I think is the max-length of all sentences in the training data. This means that self.input_x is a 56-dimensional vector which will contain just the indices from

ValueError: The shape of the input to “Flatten” is not fully defined

懵懂的女人 提交于 2019-12-08 06:54:31
问题 I'm trying to run this code, but getting the following error: Using TensorFlow backend. E c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\tensorflow\core\framework\op_kernel.cc:943] OpKernel ('op: "BestSplits" device_type: "CPU"') for unknown op: BestSplits E c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\tensorflow\core\framework\op_kernel.cc:943] OpKernel ('op: "CountExtremelyRandomStats" device_type: "CPU"') for unknown op: CountExtremelyRandomStats E c:\tf

Changing pretrained AlexNet classification in Keras

我只是一个虾纸丫 提交于 2019-12-08 05:31:49
问题 I am using a AlexNet with pretrained weights(heuritech/convnets-keras) for a classification problem with 8 classes instead of 1000. After initialising the network with Model(input=..,output=..) and loading the initial weights, I drop the last two layers, Dense(1000) and Activation(softmax), and add my own two layers: Dense(8) and Activation(softmax). But then, after running I get an error Error when checking model target: expected softmax to have shape (None, 1000) but got array with shape

TensorFlow feed an integer

风格不统一 提交于 2019-12-08 05:23:11
问题 I am trying to do a convolution over variable input sizes. To achieve that, I am using a batch size of 1. However, one of the nodes is a max pooling node which needs the shape of the input as a list ksize : pooled = tf.nn.max_pool( h, ksize=[1, self.input_size - filter_size + 1, 1, 1], strides=[1, 1, 1, 1], padding='VALID', name="pool") Now, clearly the input_size can be inferred from the input (which is a placeholder): self.input_x = tf.placeholder(tf.int32, [None, None], name="input_x") But