Although I want to modify code of convolutional nets, I could not find the main routine of the convolutional nets. The main routine is convolution and pooling.
SpatialConvolution.lua had the code below.
96 function SpatialConvolution:updateOutput(input)
97 backCompatibility(self)
98 viewWeight(self)
99 input = makeContiguous(self, input)
100 local out = input.nn.SpatialConvolutionMM_updateOutput(self, input) -- where?
101 unviewWeight(self)
102 return out
103 end
So I thought the routine was in SpatialConvolutionMM.
However, SpatialConvolutionMM.lua had the code below.
65 function SpatialConvolutionMM:updateOutput(input)
66 -- backward compatibility
67 if self.padding then
68 self.padW = self.padding
69 self.padH = self.padding
70 self.padding = nil
71 end
72 input = makeContiguous(self, input)
73 return input.nn.SpatialConvolutionMM_updateOutput(self, input) -- where??
74 end
So does anyone know where is SpatialConvolutionMM_updateOutput?
There's an open issue on GitHub for the same. One of the solution mentions upgrading nn and cunn:
luarocks install nn
luarocks install cunn
Also, take a look at this reply.
Related
I have problem with GridSearchCV freezing (CPU is active but program in not advancing) with linear svm (but with rbf svm it works fine).
Depending on the random_state that I use for splitting my data, I have this freezing in different splits points of cv for different PCA components?
The features of one sample looks like the following(it is about 39 features)
[1 117 137 2 80 16 2 39 228 88 5 6 0 10 13 6 22 23 1 227 246 7 1.656934307 0 5 0.434195726 0.010123735 0.55568054 5 275 119.48398 0.9359527 0.80484825 3.1272728 98 334 526 0.13454546 0.10181818]
Another sample's features:
[23149 4 31839 9 219 117 23 5 31897 12389 108 2 0 33 23 0 0 18 0 0 0 23149 0 0 74 0.996405221 0.003549844 4.49347E-05 74 5144 6.4480677 0.286384 0.9947901 3.833787 20 5135 14586 0.0060264384 0.011664075]
If I delete the last 10 feature I don't have this problem ( The 10 new features that I added before my code worked fine). I did not check other combinations of the 10 last new features to check if a specific feature is causing this problem.
Also I use StandardScaler to scale the features but still facing this issue. I have less of this problem if I use MinMaxScaler scaler (but read soewhere it is not good for svm).
I also put n_jobs to different numbers and it only could advance by little but freezes again.
What do you suggest?
I followed part of this code to write my code:
TypeError grid seach
So I am new to supervised machine learning, but I've been reading books and articles about it and I'm stuck on a problem. (Not stuck, but I don't understand the logic behind classification algorithms). I am trying to classify records as being wrong or not based on historical data.
So this is the original data (training data):
Name Office Age isWrong
F1 1 32 0
F2 2 61 1
F3 1 35 0
F4 0 25 0
F5 1 36 0
F6 2 52 0
F7 2 48 0
F8 1 17 1
F9 2 51 0
F10 0 24 0
F11 4 34 1
F12 0 21 0
F13 2 51 0
F14 0 27 0
F15 3 37 1
(only showing top 15 results of 200 results)
A wrong record is any record which reports an age LOWER than 18 or HIGHER than 60, or an office location that is NOT {0, 1, 2}. I have more records that display a 1 when any of the mentioned conditions are met. I trained my model with this dataset and I created a test dataset to test the results. However, I end up getting 0 on the prediction column of every record. I used a Naïve Bayes approach because this approach assumes independence between the features variables which is my case (no relationship between the office number and age). I know there are other methods like Logistic Regression and SVC(SVM), but I assume that they require a degree of relationship between the features variables. Despite that, I still tried those two approaches and got the same results. Am I doing something wrong? Do I need to specify something before training my model?
Here is what I did (very simple):
NaiveBayes nb = new NaiveBayes().setLabelCol("isWrong");
NaiveBayesModel nbm = nb.fit(dataset);
nbm.transform(dataset2).show();
Here is dataset2 (top 15):
Name Office Age
F1 9 36 //wrong, office is 9
F2 2 20
F3 1 17
F4 2 43
F5 2 90 // wrong, age is >60
F6 1 36
F7 1 40
F8 2 52
F9 2 49
F10 1 38
F11 0 28
F12 0 18
F13 1 40
F14 1 31
F15 2 45
But like I said, the prediction column displays 0 every time. Any idea why?
I don't know why you are opting for transform(). It just tries to cast the result dtype to the same one as the original column has
To get the probability you should be using the function:
predict_proba(X): Return probability estimates for the test vector X.
The following code should work perfectly in your scenario
NaiveBayes nb = new NaiveBayes().setLabelCol("isWrong");
nb.fit(dataset)
nb.predict_proba(dataset2)
I try to implement a simple ARMA model, however have serious difficulties getting it to run. When adding a parameter to the error term everything works fine (see the return x_m1 + a*e statement, commented out below), however if I add a parameter to the auto regressive part, I get a FloatingPointError or LinAlgError or PositiveDefiniteError, depending on the initialization method I use.
The code is also put into a gist you can find here. The model definition is replicated here:
with pm.Model() as model:
a = pm.Normal("a", 0, 1)
sigma = pm.Exponential('sigma', 0.1, testval=F(.1))
e = pm.Normal("e", 0, sigma, shape=(N-1,))
def x(e, x_m1, a):
# return x_m1 + a*e
return a*x_m1 + e
x, updates = theano.scan(
fn=x,
sequences=[e],
outputs_info=[tt.as_tensor_variable(data.iloc[0])],
non_sequences=[a]
)
x = pm.Deterministic('x', x)
lam = pm.Exponential('lambda', 5.0, testval=F(.1))
y = pm.StudentT("y", mu=x, lam=lam, nu=1, observed=data.values[1:]) #
with model:
trace = pm.sample(2000, init="NUTS", n_init=1000)
Here the errors respective to the initialization methods:
"ADVI" / "ADVI_MAP": FloatingPointError: NaN occurred in ADVI optimization.
"MAP": LinAlgError: 35-th leading minor not positive definite
"NUTS": PositiveDefiniteError: Scaling is not positive definite. Simple check failed. Diagonal contains negatives. Check indexes [ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71]
For details on the error messages, please look at this github issue posted at pymc3.
To be explicit, I really would like to have a scan-like solution which is easily extendable to for instance a full ARMA model. I know that one can represent the presented AR(1) model without scan by defining logP as already done in pymc3/distributions/timeseries.py#L18-L46, however I was not able to extend this vectorized style to a full ARMA model. The use of theano.scan seems preferable I think.
Any help is highly appriciated!
how make files training and testing in svm multi label?
my question is https://www.quora.com/Can-anyone-give-me-some-pointers-for-using-SVM-for-user-recognition-using-keystroke-timing/answer/Chomba-Bupe?snid3=364610243&nsrc=1&filter=all
my project is dynamic keyboard, a user vs all user for training
For example if you have three classes A, B and C you will then have 3 SVMs each with its own parameters i.e weights and biases and 3 separate outputs corresponding to the 3 classes respectively. When training SVM-A the other two classes B and C act as negative training sets while A as positive, then when training SVM-B A and C are negative training sets and for SVM-C A and B are the negatives. This is the so called one vs all training procedure.
I try but the result goes wrong
my file to training is .csv and contains:
65 134,+1
70 98,+1
73 69,+1
82 122,+1
82 95,+1
83 127,+1
84 7,+1
85 64,+1
65 123,-1
71 115,-1
73 154,-1
73 156,-1
77 164,-1
77 144,-1
79 112,-1
83 91,-1
and my file to testing is .csv and contents is:
65 111
68 88
70 103
73 89
82 111
82 79
83 112
84 36
85 71
my code is
'use strict';
var so = require('stringify-object');
var Q = require('q');
var svm = require('../lib');
var trainingFile = './archivos/training/340.txt';
var testingFile = './archivos/present/340.txt';
var clf = new svm.CSVC({
gamma: 0.25,
c: 1, // allow you to evaluate several values during training
normalize: false,
reduce: false,
kFold: 1 // disable k-fold cross-validation
});
Q.all([
svm.read(trainingFile),
svm.read(testingFile)
]).spread(function (trainingSet, testingSet) {
return clf.train(trainingSet)
.progress(function(progress){
console.log('training progress: %d%', Math.round(progress*100));
})
.then(function () {
return clf.evaluate(testingSet);
});
}).done(function (evaluationReport) {
console.log('Accuracy against the testset:\n', so(evaluationReport));
});
enter code here
Are your labels 1 and -1? If so, you will need to know those classes for your test data as well. The point of testing your classifier is to see how well it can predict unseen data.
As a small example you could build your classifier with your training data:
x_train = [65, 134], [70,98]....... [79, 112], [83, 91]
y_train = [ 1, 1, ....-1, -1]
Then you test your classifier by passing in your test data. Say you pass in the first three examples in your test data and it makes the following predictions.
[65, 111] --> 1
[68, 88] -->-1
[70,103] -->-1
You then tally up how many pieces of test data it predicted right, but in order to do that you need to know the classes of your test data to begin with. If you don't have that, perhaps you want to try cross-validation on your training data.
Just looking for some brief advice to put me back on the right track. I have been working on a solution to a problem where I have a very sparse input matrix (~25% of information filled, rest is 0's) stored in a sparse.coo_matrix:
sparse_matrix = sparse.coo_matrix((value, (rater, blurb))).toarray()
After some work on building this array from my data set and messing around with some other options, I currently have my NMF model fitter function defined as follows:
def nmf_model(matrix):
model = NMF(init='nndsvd', random_state=0)
W = model.fit_transform(matrix);
H = model.components_;
result = np.dot(W,H)
return result
Now, the issue is my output doesn't seem to be accounting for the 0 values correctly. Any value that was a 0 gets bumped to some value less than 1 and my known values fluctuate from the actual quite a bit (All data are ratings between 1 and 10). Can anyone spot what I am doing wrong? From the documentation for scikit, I assumed using the nndsvd initialization would help account for the empty values correct. Sample output:
#Row / Column / New Value
35 18 6.50746917334 #Actual Value is 6
35 19 0.580996641675 #Here down are all "estimates" of my function
35 20 1.26498699492
35 21 0.00194119935464
35 22 0.559623469753
35 23 0.109736902936
35 24 0.181657421405
35 25 0.0137801897011
35 26 0.251979684515
35 27 0.613055371646
35 28 6.17494590041 #Actual values is 5.5
Appreciate any advice any more experienced ML coders can offer!