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


Java Output类代码示例

本文整理汇总了Java中org.tensorflow.Output的典型用法代码示例。如果您正苦于以下问题:Java Output类的具体用法?Java Output怎么用?Java Output使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Output类属于org.tensorflow包,在下文中一共展示了Output类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: LabelImageTensorflowInputConverter

import org.tensorflow.Output; //导入依赖的package包/类
public LabelImageTensorflowInputConverter() {
	graph = new Graph();
	GraphBuilder b = new GraphBuilder(graph);
	// Some constants specific to the pre-trained model at:
	// https://storage.googleapis.com/download.tensorflow.org/models/inception5h.zip
	// - The model was trained with images scaled to 224x224 pixels.
	// - The colors, represented as R, G, B in 1-byte each were converted to
	//   float using (value - Mean)/Scale.
	final int H = 224;
	final int W = 224;
	final float mean = 117f;
	final float scale = 1f;

	final Output input = b.placeholder("input", DataType.STRING);
	graphOutput =
			b.div(
					b.sub(
							b.resizeBilinear(
									b.expandDims(
											b.cast(b.decodeJpeg(input, 3), DataType.FLOAT),
											b.constant("make_batch", 0)),
									b.constant("size", new int[] {H, W})),
							b.constant("mean", mean)),
					b.constant("scale", scale));

}
 
开发者ID:tzolov,项目名称:tensorflow-spring-cloud-stream-app-starters,代码行数:27,代码来源:LabelImageTensorflowInputConverter.java

示例2: constructAndExecuteGraphToNormalizeImage

import org.tensorflow.Output; //导入依赖的package包/类
private Tensor constructAndExecuteGraphToNormalizeImage(byte[] imageBytes) {
	try (Graph g = new Graph()) {
		GraphBuilder b = new GraphBuilder(g);
		// Some constants specific to the pre-trained model at:
		// https://storage.googleapis.com/download.tensorflow.org/models/inception5h.zip
		//
		// - The model was trained with images scaled to 224x224 pixels.
		// - The colors, represented as R, G, B in 1-byte each were
		// converted to
		// float using (value - Mean)/Scale.
		final int H = 224;
		final int W = 224;
		final float mean = 117f;
		final float scale = 1f;

		// Since the graph is being constructed once per execution here, we
		// can use a constant for the
		// input image. If the graph were to be re-used for multiple input
		// images, a placeholder would
		// have been more appropriate.
		final Output input = b.constant("input", imageBytes);
		final Output output = b
				.div(b.sub(
						b.resizeBilinear(b.expandDims(b.cast(b.decodeJpeg(input, 3), DataType.FLOAT),
								b.constant("make_batch", 0)), b.constant("size", new int[] { H, W })),
						b.constant("mean", mean)), b.constant("scale", scale));
		try (Session s = new Session(g)) {
			return s.runner().fetch(output.op().name()).run().get(0);
		}
	}
}
 
开发者ID:jesuino,项目名称:java-ml-projects,代码行数:32,代码来源:LabelImage.java

示例3: constructAndExecuteGraphToNormalizeImage

import org.tensorflow.Output; //导入依赖的package包/类
private static Tensor constructAndExecuteGraphToNormalizeImage(byte[] imageBytes) {
	try (Graph g = new Graph()) {
		GraphBuilder b = new GraphBuilder(g);
		// Some constants specific to the pre-trained model at:
		// https://storage.googleapis.com/download.tensorflow.org/models/inception5h.zip
		//
		// - The model was trained with images scaled to 224x224 pixels.
		// - The colors, represented as R, G, B in 1-byte each were converted to
		// float using (value - Mean)/Scale.
		final int H = 224;
		final int W = 224;
		final float mean = 117f;
		final float scale = 1f;

		// Since the graph is being constructed once per execution here, we can use a
		// constant for the
		// input image. If the graph were to be re-used for multiple input images, a
		// placeholder would
		// have been more appropriate.
		final Output input = b.constant("input", imageBytes);
		final Output output = b
				.div(b.sub(
						b.resizeBilinear(b.expandDims(b.cast(b.decodeJpeg(input, 3), DataType.FLOAT),
								b.constant("make_batch", 0)), b.constant("size", new int[] { H, W })),
						b.constant("mean", mean)), b.constant("scale", scale));
		try (Session s = new Session(g)) {
			return s.runner().fetch(output.op().name()).run().get(0);
		}
	}
}
 
开发者ID:tspannhw,项目名称:nifi-tensorflow-processor,代码行数:31,代码来源:TensorFlowService.java

示例4: constructAndExecuteGraphToNormalizeRGBImage

import org.tensorflow.Output; //导入依赖的package包/类
public static Tensor<Float> constructAndExecuteGraphToNormalizeRGBImage(byte[] imageBytes, int W, int H, float mean, float scale) {
        try (Graph g = new Graph()) {
            GraphBuilder b = new GraphBuilder(g);
            // Some constants specific to the pre-trained model at:
            // https://storage.googleapis.com/download.tensorflow.org/models/inception5h.zip
            //
            // - The model was trained with images scaled to 224x224 pixels.
            // - The colors, represented as R, G, B in 1-byte each were converted to
            //   float using (value - Mean)/Scale.
//            final int H = 224;
//            final int W = 224;
//            final float mean = 117f;
//            final float scale = 1f;

            // Since the graph is being constructed once per execution here, we can use a constant for the
            // input image. If the graph were to be re-used for multiple input images, a placeholder would
            // have been more appropriate.
            final Output<String> input = b.constant("input", imageBytes);
            final Output<Float> output
                    = b.div(
                            b.sub(
                                    b.resizeBilinear(
                                            b.expandDims(
                                                    b.cast(b.decodeJpeg(input, 3), Float.class),
                                                    b.constant("make_batch", 0)),
                                            b.constant("size", new int[]{H, W})),
                                    b.constant("mean", mean)),
                            b.constant("scale", scale));
            try (Session s = new Session(g)) {
                return s.runner().fetch(output.op().name()).run().get(0).expect(Float.class);
            }
        }
    }
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:34,代码来源:TensorFlow.java

示例5: constructAndExecuteGraphToNormalizeImage

import org.tensorflow.Output; //导入依赖的package包/类
private static Tensor<Float> constructAndExecuteGraphToNormalizeImage(byte[] imageBytes) {
  try (Graph g = new Graph()) {
    GraphBuilder b = new GraphBuilder(g);
    // Some constants specific to the pre-trained model at:
    // https://storage.googleapis.com/download.tensorflow.org/models/inception5h.zip
    //
    // - The model was trained with images scaled to 224x224 pixels.
    // - The colors, represented as R, G, B in 1-byte each were converted to
    //   float using (value - Mean)/Scale.
    final int H = 224;
    final int W = 224;
    final float mean = 117f;
    final float scale = 1f;

    // Since the graph is being constructed once per execution here, we can use a constant for the
    // input image. If the graph were to be re-used for multiple input images, a placeholder would
    // have been more appropriate.
    final Output<String> input = b.constant("input", imageBytes);
    final Output<Float> output =
        b.div(
            b.sub(
                b.resizeBilinear(
                    b.expandDims(
                        b.cast(b.decodeJpeg(input, 3), Float.class),
                        b.constant("make_batch", 0)),
                    b.constant("size", new int[] {H, W})),
                b.constant("mean", mean)),
            b.constant("scale", scale));
    try (Session s = new Session(g)) {
      return s.runner().fetch(output.op().name()).run().get(0).expect(Float.class);
    }
  }
}
 
开发者ID:loretoparisi,项目名称:tensorflow-java,代码行数:34,代码来源:LabelImage.java

示例6: constructGraphToNormalizeImage

import org.tensorflow.Output; //导入依赖的package包/类
private Graph constructGraphToNormalizeImage() {
  Graph graph = new Graph();
  GraphBuilder b = new GraphBuilder(graph);
  // - The model was trained with images scaled to 150x150 pixels.
  // - The colors, represented as R, G, B in 1-byte each were converted to
  //   float using value/Scale.
  final int H = 150;
  final int W = 150;
  final float scale = 255f;

  final Output input = b.placeholder("input", DataType.STRING);
  final Output output =
      b.div(
          b.resizeBilinear(
              b.expandDims(
                  b.cast(b.decodeJpeg(input, 3), DataType.FLOAT),
                  b.constant("make_batch", 0)),
              b.constant("size", new int[] {H, W})),
          b.constant("scale", scale));
  normalizationOutputOperationName = output.op().name();
  return graph;
}
 
开发者ID:tomwhite,项目名称:set-game,代码行数:23,代码来源:ConvNet.java

示例7: getOpType

import org.tensorflow.Output; //导入依赖的package包/类
static
public OpType getOpType(Output output){
	org.tensorflow.DataType dataType = output.dataType();

	switch(dataType){
		case FLOAT:
		case DOUBLE:
		case INT32:
		case INT64:
			return OpType.CONTINUOUS;
		case STRING:
		case BOOL:
			return OpType.CATEGORICAL;
		default:
			throw new IllegalArgumentException();
	}
}
 
开发者ID:jpmml,项目名称:jpmml-tensorflow,代码行数:18,代码来源:TypeUtil.java

示例8: constructAndExecuteGraphToNormalizeImage

import org.tensorflow.Output; //导入依赖的package包/类
private static Tensor constructAndExecuteGraphToNormalizeImage(byte[] imageBytes) {
	//Graph construction: using the OperationBuilder class to construct a graph to decode, resize and normalize a JPEG image.
	
	try (Graph g = new Graph()) {
		GraphBuilder b = new GraphBuilder(g);
		// Some constants specific to the pre-trained model at:
		// https://storage.googleapis.com/download.tensorflow.org/models/inception5h.zip
		//
		// - The model was trained with images scaled to 224x224 pixels.
		// - The colors, represented as R, G, B in 1-byte each were
		// converted to
		// float using (value - Mean)/Scale.
		final int H = 224;
		final int W = 224;
		final float mean = 117f;
		final float scale = 1f;

		// Since the graph is being constructed once per execution here, we
		// can use a constant for the
		// input image. If the graph were to be re-used for multiple input
		// images, a placeholder would
		// have been more appropriate.
		final Output input = b.constant("input", imageBytes);
		final Output output = b
				.div(b.sub(
						b.resizeBilinear(b.expandDims(b.cast(b.decodeJpeg(input, 3), DataType.FLOAT),
								b.constant("make_batch", 0)), b.constant("size", new int[] { H, W })),
						b.constant("mean", mean)), b.constant("scale", scale));
		try (Session s = new Session(g)) {
			return s.runner().fetch(output.op().name()).run().get(0);
		}
	}
}
 
开发者ID:kaiwaehner,项目名称:kafka-streams-machine-learning-examples,代码行数:34,代码来源:Kafka_Streams_TensorFlow_Image_Recognition_Example.java

示例9: constructAndExecuteGraphToNormalizeImage

import org.tensorflow.Output; //导入依赖的package包/类
private static Tensor constructAndExecuteGraphToNormalizeImage(byte[] imageBytes) {
	try (Graph g = new Graph()) {
		GraphBuilder b = new GraphBuilder(g);
		// Some constants specific to the pre-trained model at:
		// https://storage.googleapis.com/download.tensorflow.org/models/inception5h.zip
		//
		// - The model was trained with images scaled to 224x224 pixels.
		// - The colors, represented as R, G, B in 1-byte each were
		// converted to
		// float using (value - Mean)/Scale.
		final int H = 224;
		final int W = 224;
		final float mean = 117f;
		final float scale = 1f;

		// Since the graph is being constructed once per execution here, we
		// can use a constant for the
		// input image. If the graph were to be re-used for multiple input
		// images, a placeholder would
		// have been more appropriate.
		final Output input = b.constant("input", imageBytes);
		final Output output = b
				.div(b.sub(
						b.resizeBilinear(b.expandDims(b.cast(b.decodeJpeg(input, 3), DataType.FLOAT),
								b.constant("make_batch", 0)), b.constant("size", new int[] { H, W })),
						b.constant("mean", mean)), b.constant("scale", scale));
		try (Session s = new Session(g)) {
			return s.runner().fetch(output.op().name()).run().get(0);
		}
	}
}
 
开发者ID:kaiwaehner,项目名称:kafka-streams-machine-learning-examples,代码行数:32,代码来源:Kafka_Streams_TensorFlow_Image_Recognition_Example_IntegrationTest.java

示例10: decodeJpeg

import org.tensorflow.Output; //导入依赖的package包/类
Output decodeJpeg(Output contents, long channels) {
	return g.opBuilder("DecodeJpeg", "DecodeJpeg")
			.addInput(contents)
			.setAttr("channels", channels)
			.build()
			.output(0);
}
 
开发者ID:tzolov,项目名称:tensorflow-spring-cloud-stream-app-starters,代码行数:8,代码来源:LabelImageTensorflowInputConverter.java

示例11: decodeJpeg

import org.tensorflow.Output; //导入依赖的package包/类
Output decodeJpeg(Output contents, long channels) {
    return g.opBuilder("DecodeJpeg", "DecodeJpeg")
            .addInput(contents)
            .setAttr("channels", channels)
            .build()
            .output(0);
}
 
开发者ID:emara-geek,项目名称:object-recognition-tensorflow,代码行数:8,代码来源:Recognizer.java

示例12: constant

import org.tensorflow.Output; //导入依赖的package包/类
Output constant(String name, Object value) {
    try (Tensor t = Tensor.create(value)) {
        return g.opBuilder("Const", name)
                .setAttr("dtype", t.dataType())
                .setAttr("value", t)
                .build()
                .output(0);
    }
}
 
开发者ID:emara-geek,项目名称:object-recognition-tensorflow,代码行数:10,代码来源:Recognizer.java

示例13: convert

import org.tensorflow.Output; //导入依赖的package包/类
public static WritableMap convert(Output output) {
    WritableNativeMap shapeMap = new WritableNativeMap();
    shapeMap.putInt("numDimensions", output.shape().numDimensions());

    WritableNativeMap map = new WritableNativeMap();
    map.putInt("index", output.index());
    map.putString("dataType", output.dataType().name());
    map.putMap("shape", shapeMap);

    return map;
}
 
开发者ID:reneweb,项目名称:react-native-tensorflow,代码行数:12,代码来源:OutputConverter.java

示例14: outputList

import org.tensorflow.Output; //导入依赖的package包/类
@ReactMethod
public void outputList(String id, String opName, int index, int length, Promise promise) {
    try {
        Operation graphOperation = getGraphOperation(id, opName);
        Output[] outputs = graphOperation.outputList(index, length);
        WritableArray outputsConverted = new WritableNativeArray();
        for (Output output : outputs) {
            outputsConverted.pushMap(OutputConverter.convert(output));
        }
        promise.resolve(outputsConverted);
    } catch (Exception e) {
        promise.reject(e);
    }
}
 
开发者ID:reneweb,项目名称:react-native-tensorflow,代码行数:15,代码来源:RNTensorFlowGraphOperationsModule.java

示例15: constant

import org.tensorflow.Output; //导入依赖的package包/类
<T> Output<T> constant(String name, Object value, Class<T> type) {
  try (Tensor<T> t = Tensor.<T>create(value, type)) {
    return g.opBuilder("Const", name)
        .setAttr("dtype", DataType.fromClass(type))
        .setAttr("value", t)
        .build()
        .<T>output(0);
  }
}
 
开发者ID:loretoparisi,项目名称:tensorflow-java,代码行数:10,代码来源:LabelImage.java


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