neural-network

Keras GRU NN KeyError when fitting : “not in index”

不问归期 提交于 2019-12-22 05:43:08
问题 I'm currently facing an issue while trying to fit my GRU model with my training data. After a quick look on StackOverflow, I found this post to be quite similar to my issue : Simplest Lstm training with Keras io My own model is as follow : nn = Sequential() nn.add(Embedding(input_size, hidden_size)) nn.add(GRU(hidden_size_2, return_sequences=False)) nn.add(Dropout(0.2)) nn.add(Dense(output_size)) nn.add(Activation('linear')) nn.compile(loss='mse', optimizer="rmsprop") history = History() nn

Getting precision, recall and F1 score per class in Keras

跟風遠走 提交于 2019-12-22 05:37:20
问题 I have trained a neural network using the TensorFlow backend in Keras (2.1.5) and I have also used the keras-contrib (2.0.8) library in order to add a CRF layer as an output for the network. I would like to know how can I get the precision, recall and f1 score for each class after making the predictions on a test set using the NN. 回答1: Assume that you have a function get_model() that builds a your exact same model you have trained and a path weights_path pointing to your HDF5 file containing

How to apply a custom function to specific columns in a matrix in PyTorch

社会主义新天地 提交于 2019-12-22 05:32:02
问题 I have a tensor of size [150, 182, 91], the first part is just the batch size while the matrix I am interested in is the 182x91 one. I need to run a function on the 182x91 matrix for each of the 50 dimensions separately. I need to get a diagonal matrix stripe of the 182x91 matrix, and the function I am using is the following one (based on my previous question: Getting diagonal matrix stripe automatically in numpy or pytorch): def stripe(a): i, j = a.size() assert (i >= j) out = torch.zeros((i

How to apply a custom function to specific columns in a matrix in PyTorch

China☆狼群 提交于 2019-12-22 05:31:05
问题 I have a tensor of size [150, 182, 91], the first part is just the batch size while the matrix I am interested in is the 182x91 one. I need to run a function on the 182x91 matrix for each of the 50 dimensions separately. I need to get a diagonal matrix stripe of the 182x91 matrix, and the function I am using is the following one (based on my previous question: Getting diagonal matrix stripe automatically in numpy or pytorch): def stripe(a): i, j = a.size() assert (i >= j) out = torch.zeros((i

reverse word embeddings in keras - python

孤人 提交于 2019-12-22 05:13:42
问题 I am trying to make a chatbot in keras. I am assigning every word in the vocabulary its own ID. One training sample looks like this: [0 0 0 0 0 0 32 328 2839 13 192 1 ] -> [23 3289 328 2318 12 0 0 0 0 0 0 0] Then I am using the Embedding layer in Keras to embedding these ID into vectors of size 32. Then I'm using LSTM layers as the hidden layers. The problem is that my output is a list of embedded ID's like so. [ 0.16102183 0.1238187 0.1159694 0.13688719 0.12964118 0.12848872 0.13515817 0

How to build a simple RNN with a cycle in the graph in TensorFlow?

孤街浪徒 提交于 2019-12-22 05:13:40
问题 I've just started playing with TensorFlow and I'm trying to implement a very simple RNN. The RNN has x as input, y as output and consists of just a single layer that takes x and it's previous output as input. Here's a picture of the sort of thing I have in mind: The problem is, I can't see any way through the TensorFlow API to construct a graph with a cycle in it. Whenever I define a Tensor I have to specify what it's inputs are, which means I have to have already have defined it's inputs. So

What does 'Attempting to upgrade input file specified using deprecated transformation parameters' mean?

≡放荡痞女 提交于 2019-12-22 05:05:38
问题 I am currently trying to train my first net with Caffe. I get the following output: caffe train --solver=first_net_solver.prototxt I0515 09:01:06.577710 15331 caffe.cpp:117] Use CPU. I0515 09:01:06.578014 15331 caffe.cpp:121] Starting Optimization I0515 09:01:06.578097 15331 solver.cpp:32] Initializing solver from parameters: test_iter: 1 test_interval: 1 base_lr: 0.01 display: 1 max_iter: 2 lr_policy: "inv" gamma: 0.0001 power: 0.75 momentum: 0.9 weight_decay: 0 snapshot: 1 snapshot_prefix:

Overfitting after first epoch

陌路散爱 提交于 2019-12-22 04:54:06
问题 I am using convolutional neural networks (via Keras) as my model for facial expression recognition (55 subjects). My data set is quite hard and around 450k with 7 classes. I have balanced my training set per subject and per class label. I implemented a very simple CNN architecture (with real-time data augmentation): model = Sequential() model.add(Convolution2D(32, 3, 3, border_mode=borderMode, init=initialization, input_shape=(48, 48, 3))) model.add(BatchNormalization()) model.add(PReLU())

Dropout behavior in Keras with rate=1 (dropping all input units) not as expected

寵の児 提交于 2019-12-22 04:45:20
问题 input0 = keras.layers.Input((32, 32, 3), name='Input0') flatten = keras.layers.Flatten(name='Flatten')(input0) relu1 = keras.layers.Dense(256, activation='relu', name='ReLU1')(flatten) dropout = keras.layers.Dropout(1., name='Dropout')(relu1) softmax2 = keras.layers.Dense(10, activation='softmax', name='Softmax2')(dropout) model = keras.models.Model(inputs=input0, outputs=softmax2, name='cifar') just to test whether dropout is working.. I set dropout rate to be 1.0 the state in each epoch

Looping through training data in Neural Networks Backpropagation Algorithm

落爺英雄遲暮 提交于 2019-12-22 04:03:27
问题 How many times do I use a sample of training data in one training cycle? Say I have 60 training data. I go through the 1st row and do a forward pass and adjust weights using results from backward pass. Using the sigmoidal function as below: Forward pass Si = sum of (Wi * Uj) Ui = f(Si) = 1 / 1 + e^ - Si Backward pass Output Cell = (expected -Ui)(f'(Si)), where f'(Si) = Ui(1-Ui) Do I then go through the 2nd row and do the same process as the 1st or do I go around the 1st row until the error is