CNN

Passing output of a CNN to BILSTM

旧巷老猫 提交于 2021-02-08 06:15:31
问题 I am working on a project in which I have to pass the output of CNN to Bi directional LSTM. I created the model as below but it is throwing 'incompatible' error. Please let me know where I am going wrong and how to fix this model = Sequential() model.add(Conv2D(filters = 16, kernel_size = 3,input_shape = (32,32,1))) model.add(BatchNormalization()) model.add(MaxPooling2D(pool_size=(2,2),strides=1, padding='valid')) model.add(Activation('relu')) model.add(Conv2D(filters = 32, kernel_size=3))

ValueError: not enough values to unpack (expected 2, got 1)?

怎甘沉沦 提交于 2021-02-05 11:19:31
问题 def cnn_data(data): x, y = data.shape[1:] return data.reshape((-1, x, y, 1)) We introduce this function used in the following code. model.fit(cnn_data(self.train_X), np.array(self.train_y), batch_size=batch_size, epochs=num_epochs, verbose=1, class_weight=class_weight, validation_data=(cnn_data(self.val_X), np.array(self.val_y)), shuffle=True, use_multiprocessing=True, callbacks=[tensorboard, early_stopping]) The code produces the following error. It tries to train a convolutional neural

ValueError: not enough values to unpack (expected 2, got 1)?

房东的猫 提交于 2021-02-05 11:16:05
问题 def cnn_data(data): x, y = data.shape[1:] return data.reshape((-1, x, y, 1)) We introduce this function used in the following code. model.fit(cnn_data(self.train_X), np.array(self.train_y), batch_size=batch_size, epochs=num_epochs, verbose=1, class_weight=class_weight, validation_data=(cnn_data(self.val_X), np.array(self.val_y)), shuffle=True, use_multiprocessing=True, callbacks=[tensorboard, early_stopping]) The code produces the following error. It tries to train a convolutional neural

Pytorch, INPUT (normal tensor) and WEIGHT (cuda tensor) mismatch

孤街浪徒 提交于 2021-01-29 05:26:23
问题 DISCLAIMER I know, this question has already asked multiple times, but i tried their solutions, none of them worked for me, so after all those effort, i can't find anything else and eventually i have to ask again. I'm doing image classification with cnns (PYTORCH), i wan't to train it on GPU (nvidia gpu, compatible with cuda/cuda installed), i successfully managed to put net on it, but the problem is with data. if torch.cuda.is_available(): device = torch.device("cuda:0") print("Running on

Keras CNN with 1D data

淺唱寂寞╮ 提交于 2021-01-28 08:31:25
问题 Every instance of my data is an array with 72 elements. I am trying to construct a 1D cnn to do some classification but I got this error: Error when checking target: expected dense_31 to have 3 dimensions, but got array with shape (3560, 1) This is my code: training_features = np.load('features.npy') training_labels = np.load('labels.npy') training_features = training_features.reshape(-1, 72, 1) model = Sequential() model.add(Conv1D(64, 3, activation='relu', input_shape=(72, 1))) model.add

How to predict a single image with Keras ImageDataGenerator?

∥☆過路亽.° 提交于 2021-01-28 07:22:15
问题 I have trained the CNN to classify images on 3 class. while training the model i have used ImageDataGenerator class from keras to apply preprocessing function on image and rescale it. Now my network is trained with a good accuracy on test set, but i don't know how to apply preprocessing function on single image prediction. If i use ImageDataGenerator it looks for directory. Suggest me some alternatives to do preprocessing function and rescaling on single image. see my code below TRAINING SET:

Creating and shaping data for 1D CNN

…衆ロ難τιáo~ 提交于 2021-01-27 21:43:04
问题 I have a (244, 108) numpy array. It contains percentage change of close value of a trade for each minute in one day ie 108 values and like that for 244 days. Basically its a 1D vector. So in order to do 1D CNN how should I shape my data? What i have done: x.shape = (244, 108) x = np.expand_dims(x, axis=2) x.shape = (243, 108, 1) y.shape = (243,) Model: class Net(torch.nn.Module): def __init__(self): super(Net, self).__init__() self.layer1 = torch.nn.Conv1d(in_channels=108, out_channels=1,

How to map input image with neurons in first conv layer in CNN?

不想你离开。 提交于 2021-01-01 04:22:11
问题 I just completed ANN course and started learning CNN. I have basic understanding of padding and stride operation works in CNN. But have difficultly in mapping input image with neurons in first conv layer but i have basic understanding of how input features are mapped to first hidden layer in ANN. What is best way of understanding mapping between input image with neurons in first conv layer? How can I clarify my doubts about the below code example? Code is taken from DL course in Coursera. def

How to map input image with neurons in first conv layer in CNN?

China☆狼群 提交于 2021-01-01 04:21:29
问题 I just completed ANN course and started learning CNN. I have basic understanding of padding and stride operation works in CNN. But have difficultly in mapping input image with neurons in first conv layer but i have basic understanding of how input features are mapped to first hidden layer in ANN. What is best way of understanding mapping between input image with neurons in first conv layer? How can I clarify my doubts about the below code example? Code is taken from DL course in Coursera. def

Keras CNN for non-image matrix

倾然丶 夕夏残阳落幕 提交于 2020-12-12 10:53:23
问题 I have recently started learning about Deep Learning and Reinforcement Learning, and I am trying to figure out how to code a Convolutional Neural Network using Keras for a matrix of 0s and 1s with 10 rows and 3 columns. The input matrix would look like this for example [ [1, 0, 0], [0, 1, 0], [0, 0, 0], ... ] The output should be another matrix of 0s and 1s, different from the aforementioned input matrix and with a different number of rows and columns. The location of 0s and 1s in the output