neural-network

Set half of the filters of a layer as not trainable keras/tensorflow

放肆的年华 提交于 2021-02-04 14:56:22
问题 I'm trying to train a model suggested by this research paper where I set half of the filters of a convolution layer to Gabor filters and the rest are random weights which are initialized by default. Normally, if I have to set a layer as not trainable, I set the trainable attribute as False . But here I have to freeze only half of the filters of a layer and I have no idea how to do so. Any help would be really appreciated. I'm using Keras with Tensorflow backend. 回答1: How about making two

Set half of the filters of a layer as not trainable keras/tensorflow

坚强是说给别人听的谎言 提交于 2021-02-04 14:55:08
问题 I'm trying to train a model suggested by this research paper where I set half of the filters of a convolution layer to Gabor filters and the rest are random weights which are initialized by default. Normally, if I have to set a layer as not trainable, I set the trainable attribute as False . But here I have to freeze only half of the filters of a layer and I have no idea how to do so. Any help would be really appreciated. I'm using Keras with Tensorflow backend. 回答1: How about making two

Deriving the structure of a pytorch network

我是研究僧i 提交于 2021-02-04 08:03:10
问题 For my use case, I require to be able to take a pytorch module and interpret the sequence of layers in the module so that I can create a “connection” between the layers in some file format. Now let’s say I have a simple module as below class mymodel(nn.Module): def __init__(self, input_channels): super(mymodel, self).__init__() self.fc = nn.Linear(input_channels, input_channels) def forward(self, x): out = self.fc(x) out += x return out if __name__ == "__main__": net = mymodel(5) for mod in

Deriving the structure of a pytorch network

橙三吉。 提交于 2021-02-04 08:03:03
问题 For my use case, I require to be able to take a pytorch module and interpret the sequence of layers in the module so that I can create a “connection” between the layers in some file format. Now let’s say I have a simple module as below class mymodel(nn.Module): def __init__(self, input_channels): super(mymodel, self).__init__() self.fc = nn.Linear(input_channels, input_channels) def forward(self, x): out = self.fc(x) out += x return out if __name__ == "__main__": net = mymodel(5) for mod in

What to do next when Deep Learning neural network stop improving in term of validation accuracy?

余生长醉 提交于 2021-01-29 18:31:31
问题 I was running into this issue where my model converge very fast only after about 20 or 30 epoch My data set contain 7000 sample and my neural network has 3 hidden layer, each with 18 neurons and batch normalization with drop out 0.2. My task is a multi label classification where my label are [0 0 1] , [0 1 0], [1 0 0] and [0 0 0] num_neuron = 18 model = Sequential() model.add(Dense(num_neuron, input_shape=(input_size,), activation='elu')) model.add(Dropout(0.2)) model.add(keras.layers

neural network: Why is my code not reproducible?

牧云@^-^@ 提交于 2021-01-29 16:15:49
问题 I thought my neural network would be reproducible, but it is not! The results are not dramatically different but for example the loss is about 0.1 different from one run. So here is my Code! # Code reproduzierbar machen from numpy.random import seed seed(0) from tensorflow import set_random_seed set_random_seed(0) # Importiere Datasets (Training und Test) import pandas as pd poker_train = pd.read_csv("C:/Users/elihe/Documents/Studium Master/WS 19 und 20/Softwareprojekt/poker-hand-training

How can i add a Bi-LSTM layer on top of bert model?

大憨熊 提交于 2021-01-29 15:22:30
问题 I'm using pytorch and I'm using the base pretrained bert to classify sentences for hate speech. I want to implement a Bi-LSTM layer that takes as an input all outputs of the latest transformer encoder from the bert model as a new model (class that implements nn.Module ), and i got confused with the nn.LSTM parameters. I tokenized the data using bert = BertForSequenceClassification.from_pretrained("bert-base-uncased", num_labels=int(data['class'].nunique()),output_attentions=False,output

Why do we want to scale outputs when using dropout?

余生长醉 提交于 2021-01-29 14:18:47
问题 From the dropout paper: "The idea is to use a single neural net at test time without dropout. The weights of this network are scaled-down versions of the trained weights. If a unit is retained with probability p during training, the outgoing weights of that unit are multiplied by p at test time as shown in Figure 2. This ensures that for any hidden unit the expected output (under the distribution used to drop units at training time) is the same as the actual output at test time." Why do we

Error when checking target: expected dense_1 to have shape (257, 257) but got array with shape (257, 1)

*爱你&永不变心* 提交于 2021-01-29 14:10:33
问题 print(X.shape,Y.shape) #(5877, 257, 1) (5877, 257, 1) model = Sequential() model.add(LSTM(257, input_shape=(257,1),stateful=False,return_sequences=True)) model.add(Dense(257, activation='sigmoid')) model.compile(loss=losses.mean_squared_error, optimizer='adam', metrics=['accuracy']) model.fit(x=X,y=Y,epochs=100,shuffle=False) Error when checking target: expected dense_1 to have shape (257, 257) but got array with shape (257, 1) I should give 5877 frames of size 257 to lstm layer. The output

multi-label classification in python

邮差的信 提交于 2021-01-29 11:11:42
问题 I am beginning to use Pybrain which good neural networks algorithms. If anybody is familiar with it already, is the package capable of doing multi-label classification as well? Multi-label is different from multi-class classification because an instance can have more than one class as their output/target. 回答1: Your question is a bit vague. Yes I believe I've understood you correctly, and yes PyBrain is capable of doing such a task. Neural networks in Pybrain are capable (through supervised