neural-network

Train accuracy decreases with train loss

本秂侑毒 提交于 2021-01-29 09:32:54
问题 I wrote this very simple code model = keras.models.Sequential() model.add(layers.Dense(13000, input_dim=X_train.shape[1], activation='relu', trainable=False)) model.add(layers.Dense(1, input_dim=13000, activation='linear')) model.compile(loss="binary_crossentropy", optimizer='adam', metrics=["accuracy"]) model.fit(X_train, y_train, batch_size=X_train.shape[0], epochs=1000000, verbose=1) The data is MNIST but only for digits '0' and '1'. I have a very strange issue, where the loss is

Keras Sequential Model-SGD- Neural Network-NLTK

女生的网名这么多〃 提交于 2021-01-29 09:29:31
问题 creating a bot, Here i faced error after training. i trained using the Keras SEQUENTIAL Model, SGD Optimizer, NLTK lemmatizer =WordNetLemmatizer() words =pickle.load(open("words.pkl",'rb'))# reading binary mode classes= pickle.load(open("classes.pkl",'rb')) model =load_model('chatbot.model') print(classes) def clean_up_sentence(sentence): sentence_words =nltk.word_tokenize(sentence) sentence_words=[lemmatizer.lemmatize(word) for word in sentence_words] return sentence_words def bag_of_words

How to compute number of weights of CNN?

孤街醉人 提交于 2021-01-29 08:55:01
问题 How can we compute number of weights considering a convolutional neural network that is used to classify images into two classes : INPUT: 100x100 gray-scale images. LAYER 1: Convolutional layer with 60 7x7 convolutional filters (stride=1, valid padding). LAYER 2: Convolutional layer with 100 5x5 convolutional filters (stride=1, valid padding). LAYER 3: A max pooling layer that down-samples Layer 2 by a factor of 4 (e.g., from 500x500 to 250x250) LAYER 4: Dense layer with 250 units LAYER 5:

Can't init the weights of my neural network PyTorch

牧云@^-^@ 提交于 2021-01-29 08:27:29
问题 I can't initialize the weights with the function MyNet.apply(init_weights). These are my functions: def init_weights(net): if type(net) == torch.nn.Module: torch.nn.init.kaiming_uniform_(net.weight) net.bias.data.fill_(0.01) # tots els bias a 0.01 My neural net is the following: class NeuralNet(torch.nn.Module): def __init__(self): super().__init__() # Necessary for torch to detect this class as trainable # Here define network architecture self.layer1 = torch.nn.Linear(28**2, 32).to(device) #

In tensorflow, is it possible to see another models build structure?

时光毁灭记忆、已成空白 提交于 2021-01-29 06:59:33
问题 For example, if I load somebody else's model, this is what I see: I want to get the code representation of this, for example: model = Sequential() model.add(Conv2D(32, kernel_size=(3, 3), activation='relu', input_shape=input_shape)) model.add(Conv2D(64, (3, 3), activation='relu')) ... etc Not saying that the above is correct, but I want to know if there a way for me to physically reconstruct the model in code, including all activation functions? I guess I can read the summary, but I don't

XOR Neural Network sometimes outputs 0.5

吃可爱长大的小学妹 提交于 2021-01-29 06:46:26
问题 My neural network sometimes outputs crazy errors and I just don't know why after hours of searching. train(inputs: number[], outputs: number[]): void { // Verify input and output array lengths from the parameters if (outputs.length !== this.layers[this.layers.length - 1].nodeCount) throw new Error("Output Length does not match Output layer nodes."); // Calculate output error let outputError = Matrix.subtract(Matrix.from1DArray(outputs), this.predict(inputs)); // Create Array to store each

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

不羁岁月 提交于 2021-01-29 06:20:31
问题 I am trying to learn tensorflow, and I was following a demo tutorial (https://www.tensorflow.org/tutorials/keras/basic_text_classification) The error report is telling me "Error when checking target: expected dense_1 to have shape (1,) but got array with shape (256,)" Can someone explain to me why this won't work? train_data = keras.preprocessing.sequence.pad_sequences(train_data, value=word_index["<PAD>"], padding='post', maxlen=256) #max length test_data = keras.preprocessing.sequence.pad

How to compensate if I cant do a large batch size in neural network

大城市里の小女人 提交于 2021-01-29 05:34:44
问题 I am trying to run an action recognition code from GitHub. The original code used a batch size of 128 with 4 GPUS. I only have two gpus so I cannot match their bacth size number. Is there anyway I can compensate this difference in batch. I saw somewhere that iter_size might compensate according to a formula effective_batchsize= batch_size*iter_size*n_gpu . what is iter_size in this formula? I am using PYthorch not Caffe. 回答1: In pytorch, when you perform the backward step (calling loss

How to build a Neural Network to multiply two numbers

时光总嘲笑我的痴心妄想 提交于 2021-01-29 05:12:33
问题 I am trying to build a neural network which would multiply 2 numbers. To do the same, I took help of scikit-learn. I am going for a neural network with 2 hidden layers, (5, 3) and ReLU as my activation function. I have defined my MLPRegressor as follows: X = data.drop('Product', axis=1) y = data['Product'] X_train, X_test, y_train, y_test = train_test_split(X, y) scaler = StandardScaler() scaler.fit(X_train) X_train = scaler.transform(X_train) X_test = scaler.transform(X_test) mlp =

CNN pytorch : How are parameters selected and flow between layers

寵の児 提交于 2021-01-29 04:23:49
问题 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__(