conv-neural-network

How does it works the input_shape variable in Conv1d in Keras?

…衆ロ難τιáo~ 提交于 2019-12-11 19:13:02
问题 Ciao, I'm working with CNN 1d on Keras but I have tons of troubles with the input shape variable. I have a time series of 100 timesteps and 5 features with boolean labels. I want to train a CNN 1d that works with a sliding window of length 10. This is a very simple code I wrote: from keras.models import Sequential from keras.layers import Dense, Conv1D import numpy as np N_FEATURES=5 N_TIMESTEPS=10 X = np.random.rand((100, N_FEATURES)) Y = np.random.randint(0,2, size=100) # CNN model

Google Colab can't access drive content

断了今生、忘了曾经 提交于 2019-12-11 18:44:10
问题 Even though I defined my Google Drive(and my dataset in it) to google colab but when I run my code I give this error:FileNotFoundError: [Errno 2] No such file or directory: 'content/drive/My Drive/.... I already defined google drive in google colab and I can access to it through google colab but when I run my code I give this error from keras.models import Sequential from keras.layers import Convolution2D from keras.layers import MaxPooling2D from keras.layers import Flatten from keras.layers

How to apply convolution on the last three dimensions of a 5D tensor using the Conv2D in Keras?

爷,独闯天下 提交于 2019-12-11 18:39:39
问题 Usually the input tensor of the Conv2D in Keras is a 4D tensor with the dimension batch_size * n * n * channel_size . Now I have a 5D tensor with the dimension batch_size * N * n * n * channel_size and I want to apply the 2D convolutional layer for the last three dimensions for each i in N . For example, if the kernel size is 1, then I expect that the output will have the dimension batch_size * N * n * n * 1 . Anyone knows some easy ways to implement it with Keras? For example, for the fully

Caffe - Doing forward pass with multiple input blobs

╄→гoц情女王★ 提交于 2019-12-11 18:37:56
问题 Following are the input layers of my fine-tuned model: layer { type: "HDF5Data" name: "data" top: "Meta" hdf5_data_param { source: "/path/to/train.txt" batch_size: 50 } include { phase: TRAIN } } layer { name: "data" type: "ImageData" top: "X" top: "Labels" include { phase: TRAIN } transform_param { mirror: true crop_size: 227 mean_file: "data/ilsvrc12/imagenet_mean.binaryproto" } image_data_param { source: "/path/to/train.txt" batch_size: 50 new_height: 256 new_width: 256 } } layer { type:

Why is this CNN-script not predicting correctly?

允我心安 提交于 2019-12-11 18:28:10
问题 I am quite new to both Python and Machine Learning and I am working on my first real project for image recognition. It is based upon this tutorial which only has two classifications (cat or dog) and has a LOT more data. Nonetheless, I am not getting my multi-class script to work in terms of it predicting correctly but mainly how to troubleshoot the script. The script is nowhere near in predicting correctly. Below is the script. The data/images consist of 7 folders with about 10-15 images each

Keras/TF error: Incompatible shapes

会有一股神秘感。 提交于 2019-12-11 17:55:55
问题 I've got an error: InvalidArgumentError (see above for traceback): Incompatible shapes: [12192768] vs. [4064256] [[Node: mul = Mul[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"](Reshape, Reshape_1)]] Here is my code: import numpy as np import os from skimage.io import imread, imsave from keras.models import load_model, Model from keras.layers import Conv2D, MaxPooling2D, Input, concatenate, Conv2DTranspose from keras.optimizers import Adam from keras.callbacks import TensorBoard

Keras Conv2D custom kernel initialization

只谈情不闲聊 提交于 2019-12-11 17:49:05
问题 I need to initialize custom Conv2D kernels with weights W = a1b1 + a2b2 + ... + anbn where W = custom weight of Conv2D layer to initialise with a = random weight Tensors as keras.backend.variable(np.random.uniform()) , shape=(64, 1, 10) b = fixed basis filters defined as keras.backend.constant(...) , shape=(10, 11, 11) W = K.sum(a[:, :, :, None, None] * b[None, None, :, :, :], axis=2) #shape=(64, 1, 11, 11) I want my model to update the 'W' values with only changing the 'a's while keeping the

Conv2D CNN edge detection script returns blank images

早过忘川 提交于 2019-12-11 16:45:03
问题 I want to colour the oil, water and plastic in the images shown. Currently I split up the training image (only using the parts which are coloured properly). I then train a conv2D network and plot the predictions. When I run it, I get blank blue or black images in return. Please advise as to: -whether my network is appropriate, -what parameters I should be using -what training images I should be using. #IMPORT AND SPLIT from cam_img_split import cam_img_split import cv2 import numpy as np img

Maintain Array Length After ndarray.reshape

笑着哭i 提交于 2019-12-11 16:42:53
问题 I initially have an X_train size of (384, 640, 3) and a y_train size of (384,). After I reshape X_Train to (1,384,640,3) the length of X_train became 1 and I am getting the ValueError shown below. Is there a way I can still have the length of X_train be 384 without reshaping it to a 3D array? --------------------------------------------------------------------------- ValueError Traceback (most recent call last) in 1 # Training the model ----> 2 model.fit(np.array(xDataR), np.array(y_train),

High training accuracy but low prediction performance for Tensorflow's official MNIST model

陌路散爱 提交于 2019-12-11 15:51:44
问题 I'm new to machine learning and I was following along with the Tensorflow official MNIST model (https://github.com/tensorflow/models/tree/master/official/mnist). After training the model for 3 epochs and getting accuracy results of over 98%, I decided to test the dataset with some of my own handwritten images that are very close to those found in the MNIST dataset: {'loss': 0.03686057, 'global_step': 2400, 'accuracy': 0.98729998} handwritten 1, predicted as 2: https://storage.googleapis.com