Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

More expressive feature

  • Loading branch information...
commit ea720bf7f8100b90cc8ac1768788f6746e12ead7 1 parent a20bf49
Sanjeev Satheesh authored
View
20 src/rae/LabeledRAETree.java
@@ -88,20 +88,32 @@ public Integer getLabel() {
return feature;
int HiddenSize = T[0].Features.rows;
- feature = new double[ HiddenSize * 2 ];
+ feature = new double[ HiddenSize * 4 ];
DoubleMatrix tf = new DoubleMatrix(HiddenSize,TreeSize);
+ DoubleMatrix leafFeatures = new DoubleMatrix(HiddenSize,1);
+ DoubleMatrix interFeatures = new DoubleMatrix(HiddenSize,1);
if(SentenceLength > 1)
{
for(int i=0; i<TreeSize; i++)
+ {
tf.putColumn(i, T[i].Features);
+ if(T[i].isLeaf())
+ leafFeatures.add(T[i].Features);
+ else
+ interFeatures.add(T[i].Features);
+ }
tf.muli(1.0/TreeSize);
+ leafFeatures.muli(1.0/SentenceLength);
+ interFeatures.muli(1.0/(SentenceLength-1));
- System.arraycopy(T[ 2 * SentenceLength - 2 ].Features.data, 0, feature, 0, HiddenSize);
- System.arraycopy(tf.rowSums().data, 0, feature, HiddenSize, HiddenSize);
+ System.arraycopy(T[ 2 * SentenceLength - 2 ].Features.data, 0, feature, 0, HiddenSize); //root node response
+ System.arraycopy(tf.rowSums().data, 0, feature, 1*HiddenSize, HiddenSize); //average node responses
+ System.arraycopy(interFeatures.data, 0, feature, 2*HiddenSize, HiddenSize); //average leaf node responses
+ System.arraycopy(leafFeatures.data, 0, feature, 3*HiddenSize, HiddenSize); //average non-leaf node responses
}
else
{
- System.arraycopy(T[ 2 * SentenceLength - 2].Features.data, 0, feature, 0, HiddenSize);
+ System.arraycopy(T[ 2 * SentenceLength - 2].Features.data, 0, feature, 0, HiddenSize);
System.arraycopy(T[ 2 * SentenceLength - 2].Features.data, 0, feature, HiddenSize, HiddenSize);
}
return feature;
View
2  src/rae/RAECost.java
@@ -9,7 +9,6 @@
public class RAECost extends MemoizedDifferentiableFunction {
- RAECostComputer Computer;
double[] Lambda, FTLambda;
double value, AlphaCat, Beta;
DoubleMatrix WeOrig;
@@ -21,7 +20,6 @@ public RAECost(double AlphaCat, int CatSize, double Beta, int DictionaryLength,
int hiddenSize, int visibleSize, double[] Lambda, DoubleMatrix WeOrig,
List<LabeledDatum<Integer,Integer>> DataCell, FloatMatrix FreqOrig, DifferentiableMatrixFunction f) {
- Computer = new RAECostComputer(CatSize, AlphaCat, Beta, DictionaryLength, hiddenSize, DataCell, FreqOrig, f);
evalCount = 0;
this.f = f;
this.Beta = Beta;
View
2  src/rae/RAEFeatureExtractor.java
@@ -115,9 +115,9 @@ public void perform(int index, LabeledDatum<Integer, Integer> data) {
DataFeatures[index] = r;
}
lock.unlock();
- System.gc();
}
});
+ System.gc();
treeStructuresStream.close();
treeStructuresFileWriter.close();

0 comments on commit ea720bf

Please sign in to comment.
Something went wrong with that request. Please try again.