neural-network

number of neuron in output layer

独自空忆成欢 提交于 2019-12-25 02:16:24
问题 I am new to Artificial neural network but please help me with this question? I am trying to implement an artificial neural network for character recognition (using MLP, and SNN), do I need to have same number of neurons in the output layer as the numbers of characters required to be identified. For example do I need to have 26+26+10 neurons in output layer if I want my network to be able to identify capital letters, small letters and digits. what if I had to identify all the characters in the

Alignment in dimension of matrices

守給你的承諾、 提交于 2019-12-25 01:56:11
问题 I tried to run this code with my data but I obtained this error: "ValueError: shapes (3,126) and (3,126) not aligned: 126 (dim 1) != 3 (dim 0)" I'm doing the neural network and I don't want to use libraries which are suitable for Neural Network like TensorFlow. X = pd.read_excel(r"C:\\users\Hasan\Desktop\ANN\x.xlsx") y = pd.read_excel(r"C:\\users\Hasan\Desktop\ANN\y.xlsx") xPredicted = pd.read_excel(r"C:\\users\Hasan\Desktop\ANN\xpredict.xlsx") self.W1 = np.random.randn(self.inputSize, self

Is it possible to set a middle layer as an output layer in keras

我怕爱的太早我们不能终老 提交于 2019-12-25 01:24:30
问题 I would like to try out an idea about autoencoder. The model is like this: input (pictures) - conv2d - pooling - dense - dense(supervised output) - dense - conv - upsampling - output (pictures) If it is possible to train the NN having desired outputs for dense(supervised output) and output (pictures) ? In other words, I want to make a classifier-and-back. 回答1: This can be done with the Keras functional API (https://keras.io/getting-started/functional-api-guide/). A minimal example, where the

simple Feed forward (newff) network in MATLAB

不羁岁月 提交于 2019-12-24 23:17:21
问题 I used ffnew functions many times but when I am trying to create a simple feed forward network such that the input vector is P=[1;2;3;4] and the desired output is T=[1 ;0;0;1] . So i only have one sample input vector The code is net = newff(P,T,[4 1],{'tansig','tansig'}); net=train (net,P,T); When I write the last line I got: ??? Error using ==> plus Matrix dimensions must agree. Error in ==> calcperf2 at 163 N{i,ts} = N{i,ts} + Z{k}; Error in ==> trainlm at 253 [perf,El,trainV.Y,Ac,N,Zb,Zi

Raising to a square with TensorFlow with a Dataset class

爱⌒轻易说出口 提交于 2019-12-24 22:00:54
问题 I want to write a neural network which look for a x^2 distribution without a predefined model. Precisely, it is given some points in [-1,1] with their squares to train, and then it would have to reproduce and predict similar for e.g. [-10,10]. I've more or less done it - without datasets. But then I tried to modify it in order to use datasets and learn how to use it. Now, I succeded in making the program run, but the output is worse then before, mainly it's constant 0. Previous version was

SkikitLearn learning curve strongly dependent on batch size of MLPClassifier ??? Or: how to diagnose bias/ variance for NN?

倖福魔咒の 提交于 2019-12-24 20:16:44
问题 I am currently working on a classification problem with two classes in ScikitLearn with the solver adam and activation relu. To explore if my classifier suffers from high bias or high variance, I plotted the learning curve with Scikitlearns build-in function: https://scikit-learn.org/stable/auto_examples/model_selection/plot_learning_curve.html I am using a Group-K_Fold crossvalidation with 8 splits. However, I found that my learning curve is strongly dependent on the batch size of my

ValueError: multilabel-indicator is not supported for confusion matrix

怎甘沉沦 提交于 2019-12-24 19:43:16
问题 I am encountering this error when trying to use the confusion matrix in my binary classification problem. Y and Yhat are both numpy arrays. I have tried the .argmax as the proposed solution - I don't get the error anymore but the output is not the confusion matrix that I know. Accuracy: 0.9982449999999999 Accuracy: 0.9983374013937532 shape of y = (1, 200000) shape of yhat = (1, 200000) The error ValueError Traceback (most recent call last) <ipython-input-13-ebb660b4585a> in <module>() 12

Loss decreases when using semi hard triplets

南笙酒味 提交于 2019-12-24 19:17:19
问题 Here is a short review of triplet learning. I'm using three convolutional neural networks with shared weights in order to generate faces embeddings ( anchor , positive , negative ), with the loss described here. Triplet loss: anchor_output = ... # shape [None, 128] positive_output = ... # shape [None, 128] negative_output = ... # shape [None, 128] d_pos = tf.reduce_sum(tf.square(anchor_output - positive_output), 1) d_neg = tf.reduce_sum(tf.square(anchor_output - negative_output), 1) loss = tf

Make a Custom loss function in Keras in detail

喜欢而已 提交于 2019-12-24 19:04:51
问题 I try to make a custom loss function in Keras. I want to make this loss function The dimension of output is 80. Batch size is 5000. So I build this loss function below. But this doesn't work. def normalize_activation(y_true, y_pred): nb_divide = K.reshape(K.sqrt(K.sum(K.square(y_pred), axis=1)),(5000, 1)) nb_divide=numpy.tile(nb_divide,80) predicted=numpy.divide(y_pred,nb_divide) return K.sum(K.square(y_true-predicted)) ValueError: setting an array element with a sequence. This error occurs.