當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。