neural-network

CNN pytorch : How are parameters selected and flow between layers

↘锁芯ラ 提交于 2021-01-29 04:23:28
问题 I'm pretty new to CNN and have been following the below code. I'm not able to understand how and why have we selected the each argument of Conv2d() and nn.Linear () as they are i.e. the output, filter, channels, weights,padding and stride. I do understand the meaning of each though. Can someone very succinctly explain the flow for each layer? (Input Image Size is 32*32*3) import torch.nn as nn import torch.nn.functional as F class Net(nn.Module): def __init__(self): super(Net, self).__init__(

Should I shuffle the data to train a neural network using backpropagation?

喜夏-厌秋 提交于 2021-01-29 02:34:03
问题 I want to train a neural network using backpropagation, and I have a data set like this: Should I shuffle the input data? 回答1: Yes, and it should be shuffled at each iteration, e.g. quote from {1}: As for any stochastic gradient descent method (including the mini-batch case), it is important for efficiency of the estimator that each example or minibatch be sampled approximately independently. Because random access to memory (or even worse, to disk) is expensive, a good approximation, called

How to apply a different dense layer for each timestep in Keras

天涯浪子 提交于 2021-01-29 02:22:33
问题 I know that applying a TimeDistributed(Dense) applies the same dense layer over all the timesteps but I wanted to know how to apply different dense layers for each timestep. The number of timesteps is not variable. P.S.: I have seen the following link and can't seem to find an answer 回答1: You can use a LocallyConnected layer. The LocallyConnected layer words as a Dense layer connected to each of kernel_size time_steps (1 in this case). from tensorflow import keras from tensorflow.keras.layers

How to apply a different dense layer for each timestep in Keras

风格不统一 提交于 2021-01-29 02:21:30
问题 I know that applying a TimeDistributed(Dense) applies the same dense layer over all the timesteps but I wanted to know how to apply different dense layers for each timestep. The number of timesteps is not variable. P.S.: I have seen the following link and can't seem to find an answer 回答1: You can use a LocallyConnected layer. The LocallyConnected layer words as a Dense layer connected to each of kernel_size time_steps (1 in this case). from tensorflow import keras from tensorflow.keras.layers

Change Hyperparameters on an ongoing simulation of TensorFlow

为君一笑 提交于 2021-01-28 11:22:21
问题 I wonder if it is possible to change some hyperparameters, let's say learning rate or regularization in real time during a TensorFlow simulation. Something like: You are monitoring the cost function of your neural net(NN) and then you decide that your NN could be doing better if you reduce the regularization term. But you would like to do this without interrupting everything. Just typing the new value in somewhere and then changing the regularization in the next epoch, for example. 回答1: You

Mini batches with DataLoader and a 3D input. (Pytorch)

做~自己de王妃 提交于 2021-01-28 06:50:47
问题 I have been struggling to manage and create batches for a 3D tensor. I have used it before as a way to create batches for 1D tensor. However, in my current research, I need to create batches out of a tensor with shape (1024,1024,2). I created custom data to use as my input for the DataLoader method in pytorch. I created the following for the 1D array: class CustomDataset(Dataset): def __init__(self, x_tensor, y_tensor): self.xdomain = x_tensor self.ydomain = y_tensor def __getitem__(self,

Keras ValueError: Dimensions must be equal, but are 9 and 400 for '{{node Equal}}' with input shapes: [?,9], [?,300,400]

我们两清 提交于 2021-01-28 06:11:48
问题 I'm trying to train a very simple Keras network to classify some one-hot encoded images saved as np.array . The input data structure is made of a .npy file, with 500 images (3 arrays each one, as it's RGB) and a one-hot encoded array with each image to determine it's classification. Each image is 400x300 pixels (Width x Height), and the target output should be of 9 classes. Hence, each image has a shape of (300, 400, 3) and each one-hot encoded label list has a length of 9 . This is the code

Add learning rate to history object of fit_generator with Tensorflow

三世轮回 提交于 2021-01-28 05:13:46
问题 I want to check how my optimizer is changing my learning rate. I am using tensorflow 1.15. I run my model with fit_generator: hist = model.fit_generator(dat, args.onthefly[0]//args.batch, args.epochs, validation_data=val, validation_steps=args.onthefly[1]//args.batch,verbose=2, use_multiprocessing=True, workers=56) I choose the optimizer using the compile function: model.compile(loss=loss, optimizer=Nadam(lr=learning_rate), metrics=['binary_accuracy'] ) How can I get the value of the learning

Average layer in multi input deep learning

不想你离开。 提交于 2021-01-27 20:35:51
问题 I am working to create a multi-input Convolutional Neural Network (CNN) model in Keras for Images Classification that takes two images and gives one output which is the class of the two images. I have two datasets: type1 and type2, and each dataset contains the same classes. The model should take one image from Type1 dataset and one image from Type2 dataset and then classify these images to one class (ClassA or ClassB or------). I want to create a model that predict the two images and then

neural network does not learn (loss stays the same)

我与影子孤独终老i 提交于 2021-01-27 13:14:35
问题 My project partner and I are currently facing a problem in our latest university project. Our mission is to implement a neural network that plays the game Pong. We are giving the ball position the ball speed and the position of the paddles to our network and have three outputs: UP DOWN DO_NOTHING. After a player has 11 points we train the network with all states, the made decisions and the reward of the made decisions (see reward_cal()). The problem we are facing is, that the loss is