当前位置: 首页>>代码示例>>Java>>正文


Java Function类代码示例

本文整理汇总了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;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:36,代码来源:RangedDBSCANClusterEvaluator.java

示例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;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:29,代码来源:ClusterEvaluator.java

示例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);
	}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:31,代码来源:WineDatasetExperiment.java

示例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;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:11,代码来源:CombinedMetaPayloadFunction.java

示例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());
		}
	};
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:15,代码来源:AbstractStream.java

示例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;
		}

	};
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:15,代码来源:IndependentPair.java

示例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;
		}
	};
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:14,代码来源:IndependentPair.java

示例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;
		}

	};
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:67,代码来源:OnlineBackpropOneHidden.java

示例9: FeatureExtractionFunction

import org.openimaj.util.function.Function; //导入依赖的package包/类
public FeatureExtractionFunction(Function<INPUT, FEATURE> func) {
	this.func = func;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:4,代码来源:FeatureExtractionFunction.java

示例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);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:4,代码来源:FeatureExtractionFunction.java

示例11: IRecordWrapper

import org.openimaj.util.function.Function; //导入依赖的package包/类
public IRecordWrapper(Function<A, B> extract) {
	this.inner = extract;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:4,代码来源:UKBenchGMMExperiment.java

示例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);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:4,代码来源:UKBenchGMMExperiment.java

示例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;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:51,代码来源:VLADIndexerDataBuilder.java

示例14: getPostProcess

import org.openimaj.util.function.Function; //导入依赖的package包/类
/**
 * @return the postProcess
 */
public Function<List<? extends LocalFeature<?, ?>>, List<FloatLocalFeatureAdaptor<?>>> getPostProcess() {
	return postProcess;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:7,代码来源:VLADIndexerData.java

示例15: WindowFunction

import org.openimaj.util.function.Function; //导入依赖的package包/类
/**
 * @param fun
 */
public WindowFunction(Function<IN,OUT> fun) {
	this.fun = fun;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:7,代码来源:WindowFunction.java


注:本文中的org.openimaj.util.function.Function类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。