本文整理了Java中org.apache.mahout.math.Vector.logNormalize()
方法的一些代码示例,展示了Vector.logNormalize()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Vector.logNormalize()
方法的具体详情如下:
包路径:org.apache.mahout.math.Vector
类名称:Vector
方法名:logNormalize
[英]Return a new vector containing the log(1 + entry)/ L_2 norm values of the recipient
[中]返回一个新向量,其中包含收件人的log(1+条目)/L_2范数值
代码示例来源:origin: apache/mahout
@Override
public Vector logNormalize(double power) {
return delegate.logNormalize(power);
}
代码示例来源:origin: apache/mahout
@Override
public Vector logNormalize() {
return delegate.logNormalize();
}
代码示例来源:origin: apache/mahout
@Override
public Vector logNormalize(double power) {
return delegate.logNormalize(power);
}
代码示例来源:origin: apache/mahout
@Override
public Vector logNormalize() {
return delegate.logNormalize();
}
代码示例来源:origin: apache/mahout
vec1.setQuick(1, 2);
vec1.setQuick(2, 3);
Vector norm = vec1.logNormalize();
assertNotNull("norm1 is null and it shouldn't be", norm);
vec2.setQuick(1, 2);
vec2.setQuick(2, 3);
Vector norm2 = vec2.logNormalize();
assertNotNull("norm1 is null and it shouldn't be", norm2);
norm = vec1.logNormalize(2);
assertVectorEquals(expected, norm, 1.0e-15);
norm2 = vec2.logNormalize(2);
assertVectorEquals(expected, norm2, 1.0e-15);
vec1.logNormalize(1);
fail("Should fail with power == 1");
} catch (IllegalArgumentException e) {
vec1.logNormalize(-1);
fail("Should fail with negative power");
} catch (IllegalArgumentException e) {
vec2.logNormalize(Double.POSITIVE_INFINITY);
fail("Should fail with positive infinity norm");
} catch (IllegalArgumentException e) {
代码示例来源:origin: apache/mahout
assertEquals(0, dv1.logNormalize().getDistanceSquared(v1.logNormalize()), FUZZ);
assertEquals(0, dv1.logNormalize(1.5).getDistanceSquared(v1.logNormalize(1.5)), FUZZ);
代码示例来源:origin: org.apache.mahout/mahout-math
@Override
public Vector logNormalize() {
return delegate.logNormalize();
}
代码示例来源:origin: org.apache.mahout/mahout-math
@Override
public Vector logNormalize(double power) {
return delegate.logNormalize(power);
}
代码示例来源:origin: org.apache.mahout/mahout-math
@Override
public Vector logNormalize() {
return delegate.logNormalize();
}
代码示例来源:origin: cloudera/mahout
@Override
public Vector logNormalize() {
return delegate.logNormalize();
}
代码示例来源:origin: org.apache.mahout/mahout-math
@Override
public Vector logNormalize(double power) {
return delegate.logNormalize(power);
}
代码示例来源:origin: cloudera/mahout
@Override
public Vector logNormalize(double power) {
return delegate.logNormalize(power);
}
代码示例来源:origin: org.apache.mahout/mahout-mr
@Override
protected void reduce(WritableComparable<?> key, Iterable<VectorWritable> values, Context context) throws IOException,
InterruptedException {
Vector vector = null;
for (VectorWritable value : values) {
if (vector == null) {
vector = value.get().clone();
continue;
}
//value.get().addTo(vector);
vector.assign(value.get(), Functions.PLUS);
}
if (vector != null && normPower != PartialVectorMerger.NO_NORMALIZING) {
vector = logNormalize ? vector.logNormalize(normPower) : vector.normalize(normPower);
}
VectorWritable vectorWritable = new VectorWritable(vector);
context.write(key, vectorWritable);
}
代码示例来源:origin: org.apache.mahout/mahout-mrlegacy
@Override
protected void reduce(WritableComparable<?> key, Iterable<VectorWritable> values, Context context) throws IOException,
InterruptedException {
Vector vector = null;
for (VectorWritable value : values) {
if (vector == null) {
vector = value.get().clone();
continue;
}
//value.get().addTo(vector);
vector.assign(value.get(), Functions.PLUS);
}
if (vector != null && normPower != PartialVectorMerger.NO_NORMALIZING) {
vector = logNormalize ? vector.logNormalize(normPower) : vector.normalize(normPower);
}
VectorWritable vectorWritable = new VectorWritable(vector);
context.write(key, vectorWritable);
}
代码示例来源:origin: org.apache.mahout/mahout-core
@Override
protected void reduce(WritableComparable<?> key, Iterable<VectorWritable> values, Context context) throws IOException,
InterruptedException {
Vector vector = null;
for (VectorWritable value : values) {
if (vector == null) {
vector = value.get().clone();
continue;
}
//value.get().addTo(vector);
vector.assign(value.get(), Functions.PLUS);
}
if (vector != null && normPower != PartialVectorMerger.NO_NORMALIZING) {
vector = logNormalize ? vector.logNormalize(normPower) : vector.normalize(normPower);
}
VectorWritable vectorWritable = new VectorWritable(vector);
context.write(key, vectorWritable);
}
代码示例来源:origin: org.apache.mahout/mahout-core
@Override
protected void reduce(WritableComparable<?> key, Iterable<VectorWritable> values, Context context) throws IOException,
InterruptedException {
Vector vector = new RandomAccessSparseVector(dimension, 10);
for (VectorWritable value : values) {
vector.assign(value.get(), Functions.PLUS);
}
if (normPower != PartialVectorMerger.NO_NORMALIZING) {
if (logNormalize) {
vector = vector.logNormalize(normPower);
} else {
vector = vector.normalize(normPower);
}
}
if (sequentialAccess) {
vector = new SequentialAccessSparseVector(vector);
}
if (namedVector) {
vector = new NamedVector(vector, key.toString());
}
// drop empty vectors.
if (vector.getNumNondefaultElements() > 0) {
VectorWritable vectorWritable = new VectorWritable(vector);
context.write(key, vectorWritable);
}
}
代码示例来源:origin: org.apache.mahout/mahout-mr
@Override
protected void reduce(WritableComparable<?> key, Iterable<VectorWritable> values, Context context) throws IOException,
InterruptedException {
Vector vector = new RandomAccessSparseVector(dimension, 10);
for (VectorWritable value : values) {
vector.assign(value.get(), Functions.PLUS);
}
if (normPower != PartialVectorMerger.NO_NORMALIZING) {
if (logNormalize) {
vector = vector.logNormalize(normPower);
} else {
vector = vector.normalize(normPower);
}
}
if (sequentialAccess) {
vector = new SequentialAccessSparseVector(vector);
}
if (namedVector) {
vector = new NamedVector(vector, key.toString());
}
// drop empty vectors.
if (vector.getNumNondefaultElements() > 0) {
VectorWritable vectorWritable = new VectorWritable(vector);
context.write(key, vectorWritable);
}
}
代码示例来源:origin: org.apache.mahout/mahout-mrlegacy
@Override
protected void reduce(WritableComparable<?> key, Iterable<VectorWritable> values, Context context) throws IOException,
InterruptedException {
Vector vector = new RandomAccessSparseVector(dimension, 10);
for (VectorWritable value : values) {
vector.assign(value.get(), Functions.PLUS);
}
if (normPower != PartialVectorMerger.NO_NORMALIZING) {
if (logNormalize) {
vector = vector.logNormalize(normPower);
} else {
vector = vector.normalize(normPower);
}
}
if (sequentialAccess) {
vector = new SequentialAccessSparseVector(vector);
}
if (namedVector) {
vector = new NamedVector(vector, key.toString());
}
// drop empty vectors.
if (vector.getNumNondefaultElements() > 0) {
VectorWritable vectorWritable = new VectorWritable(vector);
context.write(key, vectorWritable);
}
}
代码示例来源:origin: cloudera/mahout
vec1.setQuick(1, 2);
vec1.setQuick(2, 3);
Vector norm = vec1.logNormalize();
assertNotNull("norm1 is null and it shouldn't be", norm);
vec2.setQuick(1, 2);
vec2.setQuick(2, 3);
Vector norm2 = vec2.logNormalize();
assertNotNull("norm1 is null and it shouldn't be", norm2);
norm = vec1.logNormalize(2);
assertVectorEquals(expected, norm, 1.0e-15);
norm2 = vec2.logNormalize(2);
assertVectorEquals(expected, norm2, 1.0e-15);
vec1.logNormalize(1);
fail("Should fail with power == 1");
} catch (IllegalArgumentException e) {
vec1.logNormalize(-1);
fail("Should fail with negative power");
} catch (IllegalArgumentException e) {
vec2.logNormalize(Double.POSITIVE_INFINITY);
fail("Should fail with positive infinity norm");
} catch (IllegalArgumentException e) {
内容来源于网络,如有侵权,请联系作者删除!