本文整理汇总了Java中org.openimaj.util.function.Function类的典型用法代码示例。如果您正苦于以下问题:Java Function类的具体用法?Java Function怎么用?Java Function使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Function类属于org.openimaj.util.function包,在下文中一共展示了Function类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: RangedDBSCANClusterEvaluator
import org.openimaj.util.function.Function; //导入依赖的package包/类
/**
* @param r
* the range of values for the {@link SparseMatrixDBSCAN} eps
* value
* @param gen
* @param data
* @param indexFunc
* given a data instance, return its index
* @param dataset
* @param analyser
*/
public <A, B> RangedDBSCANClusterEvaluator(
UniformDoubleRangeIterable r,
SparseMatrixDBSCAN gen,
SparseMatrix data,
Function<B, Integer> indexFunc,
Map<A, ? extends List<B>> dataset,
ClusterAnalyser<T> analyser)
{
this.r = r;
this.gen = gen;
this.correct = new int[dataset.size()][];
int j = 0;
for (final Entry<A, ? extends List<B>> es : dataset.entrySet()) {
this.correct[j] = new int[es.getValue().size()];
int i = 0;
final List<B> value = es.getValue();
for (final B b : value) {
this.correct[j][i++] = indexFunc.apply(b);
}
j++;
}
this.analyser = analyser;
this.data = data;
}
示例2: ClusterEvaluator
import org.openimaj.util.function.Function; //导入依赖的package包/类
/**
* @param gen
* @param data
* @param indexFunc given a data instance, return its index
* @param dataset
* @param analyser
*/
public <A,B> ClusterEvaluator(
Clusterer<D> gen,
D data,
Function<B,Integer> indexFunc,
Map<A,? extends List<B>> dataset,
ClusterAnalyser<T> analyser) {
this.gen = gen;
this.correct = new int[dataset.size()][];
int j = 0;
for (Entry<A, ? extends List<B>> es : dataset.entrySet()) {
this.correct[j] = new int[es.getValue().size()];
int i = 0;
List<B> value = es.getValue();
for (B b : value) {
this.correct[j][i++] = indexFunc.apply(b);
}
j++;
}
this.analyser = analyser;
this.data = data;
}
示例3: main
import org.openimaj.util.function.Function; //导入依赖的package包/类
/**
* @param args
*/
public static void main(String[] args) {
WineDataset ds = new WineDataset(2,3);
// logger.info("Clustering using spectral clustering");
// DoubleSpectralClustering clust = prepareSpectralClustering();
// ClustererWrapper spectralWrapper = new NormalisedSimilarityDoubleClustererWrapper<double[]>(
// ds,
// new WrapperExtractor(),
// clust,
// MAXIMUM_DISTANCE
// );
// evaluate(ds, clust);
// logger.info("Clustering using DBScan");
// DoubleDBSCAN dbScan = prepareDBScane();
// ClustererWrapper dbScanWrapper = new NormalisedSimilarityDoubleClustererWrapper<double[]>(
// ds,
// new WrapperExtractor(),
// dbScan,
// MAXIMUM_DISTANCE
// );
// evaluate(ds, dbScan);
logger.info("Clustering using modified spectral clustering");
DoubleSpectralClustering clustCSP = prepareCSPSpectralClustering(ds);
Function<List<double[]>,SparseMatrix> func = new RBFSimilarityDoubleClustererWrapper<double[]>(new DummyExtractor());
evaluate(ds, clustCSP, func);
}
示例4: CombinedMetaPayloadFunction
import org.openimaj.util.function.Function; //导入依赖的package包/类
/**
* @param fA
* @param fB
*/
public CombinedMetaPayloadFunction(Function<MetaPayload<AIN, AM>, MetaPayload<AOUT, AM>> fA,
Function<MetaPayload<BIN, BM>, MetaPayload<BOUT, BM>> fB)
{
this.fA = fA;
this.fB = fB;
}
示例5: map
import org.openimaj.util.function.Function; //导入依赖的package包/类
@Override
public <R> Stream<R> map(final Function<T, R> mapper) {
return new AbstractStream<R>() {
@Override
public boolean hasNext() {
return AbstractStream.this.hasNext();
}
@Override
public R next() {
return mapper.apply(AbstractStream.this.next());
}
};
}
示例6: getFirstFunction
import org.openimaj.util.function.Function; //导入依赖的package包/类
/**
* Get the function that returns the first object from the pair
*
* @return the function that returns the first object from the pair
*/
public static <T, Q> Function<IndependentPair<T, Q>, T> getFirstFunction() {
return new Function<IndependentPair<T, Q>, T>() {
@Override
public T apply(IndependentPair<T, Q> in) {
return in.o1;
}
};
}
示例7: getSecondFunction
import org.openimaj.util.function.Function; //导入依赖的package包/类
/**
* Get the function that returns the second object from the pair
*
* @return the function that returns the second object from the pair
*/
public static <T, Q> Function<IndependentPair<T, Q>, Q> getSecondFunction() {
return new Function<IndependentPair<T, Q>, Q>() {
@Override
public Q apply(IndependentPair<T, Q> in) {
return in.o2;
}
};
}
示例8: OnlineBackpropOneHidden
import org.openimaj.util.function.Function; //导入依赖的package包/类
/**
* @param nInput
* the number of input values
* @param nHidden
* the number of hidden values
* @param nFinal
* the number of final values
*/
public OnlineBackpropOneHidden(int nInput, int nHidden, int nFinal) {
final double[][] weightsL1dat = RandomData.getRandomDoubleArray(nInput + 1, nHidden, -1, 1.);
final double[][] weightsL2dat = RandomData.getRandomDoubleArray(nHidden + 1, nFinal, -1, 1.);
weightsL1 = DMF.copyArray(weightsL1dat);
weightsL2 = DMF.copyArray(weightsL2dat);
;
g = new Function<Double, Double>() {
@Override
public Double apply(Double in) {
return 1. / (1 + Math.exp(-in));
}
};
gPrime = new Function<Double, Double>() {
@Override
public Double apply(Double in) {
return g.apply(in) * (1 - g.apply(in));
}
};
gPrimeMat = new Function<Matrix, Matrix>() {
@Override
public Matrix apply(Matrix in) {
final Matrix out = DMF.copyMatrix(in);
for (int i = 0; i < in.getNumRows(); i++) {
for (int j = 0; j < in.getNumColumns(); j++) {
out.setElement(i, j, gPrime.apply(in.getElement(i, j)));
}
}
return out;
}
};
gMat = new Function<Matrix, Matrix>() {
@Override
public Matrix apply(Matrix in) {
final Matrix out = DMF.copyMatrix(in);
for (int i = 0; i < in.getNumRows(); i++) {
for (int j = 0; j < in.getNumColumns(); j++) {
out.setElement(i, j, g.apply(in.getElement(i, j)));
}
}
return out;
}
};
}
示例9: FeatureExtractionFunction
import org.openimaj.util.function.Function; //导入依赖的package包/类
public FeatureExtractionFunction(Function<INPUT, FEATURE> func) {
this.func = func;
}
示例10: wrap
import org.openimaj.util.function.Function; //导入依赖的package包/类
public static <FEATURE, INPUT> FeatureExtractionFunction<FEATURE, INPUT> wrap(Function<INPUT, FEATURE> func) {
return new FeatureExtractionFunction<FEATURE, INPUT>(func);
}
示例11: IRecordWrapper
import org.openimaj.util.function.Function; //导入依赖的package包/类
public IRecordWrapper(Function<A, B> extract) {
this.inner = extract;
}
示例12: wrap
import org.openimaj.util.function.Function; //导入依赖的package包/类
public static <A, B> Function<IRecord<A>, B> wrap(Function<A, B> extract) {
return new IRecordWrapper<A, B>(extract);
}
示例13: VLADIndexerDataBuilder
import org.openimaj.util.function.Function; //导入依赖的package包/类
/**
* Construct a {@link VLADIndexerDataBuilder} with the given parameters
*
* @param extractor
* the local feature extractor used to generate the input
* features
* @param localFeatures
* a list of file locations of the files containing the input
* local features (one per image)
* @param normalise
* should the resultant VLAD features be l2 normalised?
* @param numVladCentroids
* the number of centroids for VLAD (~64)
* @param numIterations
* the number of clustering iterations (~100)
* @param numPcaDims
* the number of dimensions to project down to using PCA (~128
* for normal SIFT)
* @param numPqIterations
* the number of iterations for clustering the product quantisers
* (~100)
* @param numPqAssigners
* the number of product quantiser assigners (~16)
* @param sampleProp
* the proportion of features to sample for the clustering the
* VLAD centroids
* @param pcaSampleProp
* the proportion of images to sample for computing the PCA basis
* @param postProcess
* the post-processing to apply to the raw features before input
* to VLAD
*/
public VLADIndexerDataBuilder(LocalFeatureExtractor<LocalFeature<?, ?>, MBFImage> extractor,
List<File> localFeatures, boolean normalise, int numVladCentroids, int numIterations, int numPcaDims,
int numPqIterations, int numPqAssigners, float sampleProp, float pcaSampleProp,
Function<List<? extends LocalFeature<?, ?>>, List<FloatLocalFeatureAdaptor<?>>> postProcess)
{
super();
this.extractor = extractor;
this.localFeatures = localFeatures;
this.normalise = normalise;
this.numVladCentroids = numVladCentroids;
this.numIterations = numIterations;
this.numPcaDims = numPcaDims;
this.numPqIterations = numPqIterations;
this.numPqAssigners = numPqAssigners;
this.sampleProp = sampleProp;
this.pcaSampleProp = pcaSampleProp;
this.postProcess = postProcess == null ? StandardPostProcesses.NONE : postProcess;
}
示例14: getPostProcess
import org.openimaj.util.function.Function; //导入依赖的package包/类
/**
* @return the postProcess
*/
public Function<List<? extends LocalFeature<?, ?>>, List<FloatLocalFeatureAdaptor<?>>> getPostProcess() {
return postProcess;
}
示例15: WindowFunction
import org.openimaj.util.function.Function; //导入依赖的package包/类
/**
* @param fun
*/
public WindowFunction(Function<IN,OUT> fun) {
this.fun = fun;
}