Note that there are some explanatory texts on larger screens.

plurals
  1. PONot able to update elements in arrayList
    text
    copied!<p>I have two matrices for feature and weight elements.I am implementing an learning algorithm. I want to update elements of arraylist(vector for representing one sample of feature). Following is the code. But my elements of matrices(vector elements are not) updated. I have put the sample solution too. same value before and after updating is not expected. Could you please let me know where is the flaw in code? </p> <pre><code> for(int i =0 ; i&lt; N ; i++){ //N is a large real number ArrayList&lt;Double&gt; featureVector = new ArrayList&lt;Double&gt;(); featureVector = FeatureMatrix.get(i); System.out.println("Before::"+ featureVector); if(testList.contains(i)){ for(int j=0 ; j&lt; testList.size(); j++){ if(i == testList.get(j)){ int indexInTestList= j; List&lt;Double&gt; subListNextCandidate ; subListNextCandidate = weightVectorNextCandidate.subList((10*indexIntTestList),((10)*(indexInTestList+1))); //clips a portion of member from long list of members List&lt;Double&gt; approxWeight = new ArrayList&lt;Double&gt;(); approxWeight = getApproxWeight(FeatureVector, indexInTestList, FeatureMatrix,WeightMatrix, bias); //approxWeight is a vector of same dimension as of featureVector for(int l=0 ; l&lt; 10;l++){ double Update = featureVector.get(l)+ Rate*((subListCandidate.get(l)-approxWeight.get(l))-(lambda*featureVector.get(l)*(1/M)));//M is large real number featureVector.set(l,Update); } } } } else{ for(int l=0 ; l&lt; 10;l++){ double Update = featureVector.get(l) -Rate*(lambda*featureVector.get(l)*(1/M)); featureVector.set(l, Update); } } System.out.println("After:::"+ FeatureMatrix.get(i) ); } </code></pre> <p>Sample output is::</p> <pre><code> Before::[0.04539928251182193, -0.16233604402485394, 0.905018369795912, -1.2817141994528614, 0.7065420460225843, -0.8946090188977665, -1.74892020689701, -2.1539901172158187, 1.8229765478806985, -1.8109945435256574] After:::[0.04539928251182193, -0.16233604402485394, 0.905018369795912, -1.2817141994528614, 0.7065420460225843, -0.8946090188977665, -1.74892020689701, -2.1539901172158187, 1.8229765478806985, -1.8109945435256574] </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload