• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Operation类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getOperation

import org.tensorflow.Operation; //导入依赖的package包/类
public Operation getOperation(String id, String name) {
    Graph graph = graphs.get(id);
    if(graph != null && name != null) {
        return graph.operation(name);
    } else {
        return null;
    }
}
 
开发者ID:reneweb,项目名称:react-native-tensorflow,代码行数:9,代码来源:RNTensorFlowGraphModule.java


示例2: graphOperation

import org.tensorflow.Operation; //导入依赖的package包/类
public Operation graphOperation(String operationName) {
  final Operation operation = g.operation(operationName);
  if (operation == null) {
    throw new RuntimeException(
        "Node '" + operationName + "' does not exist in model '" + modelName + "'");
  }
  return operation;
}
 
开发者ID:Jamjomjara,项目名称:snu-artoon,代码行数:9,代码来源:TensorFlowInferenceInterface.java


示例3: inputListLength

import org.tensorflow.Operation; //导入依赖的package包/类
@ReactMethod
public void inputListLength(String id, String opName, String name, Promise promise) {
    try {
        Operation graphOperation = getGraphOperation(id, opName);
        promise.resolve(graphOperation.inputListLength(name));
    } catch (Exception e) {
        promise.reject(e);
    }
}
 
开发者ID:reneweb,项目名称:react-native-tensorflow,代码行数:10,代码来源:RNTensorFlowGraphOperationsModule.java


示例4: name

import org.tensorflow.Operation; //导入依赖的package包/类
@ReactMethod
public void name(String id, String opName, Promise promise) {
    try {
        Operation graphOperation = getGraphOperation(id, opName);
        promise.resolve(graphOperation.name());
    } catch (Exception e) {
        promise.reject(e);
    }
}
 
开发者ID:reneweb,项目名称:react-native-tensorflow,代码行数:10,代码来源:RNTensorFlowGraphOperationsModule.java


示例5: numOutputs

import org.tensorflow.Operation; //导入依赖的package包/类
@ReactMethod
public void numOutputs(String id, String opName, Promise promise) {
    try {
        Operation graphOperation = getGraphOperation(id, opName);
        promise.resolve(graphOperation.numOutputs());
    } catch (Exception e) {
        promise.reject(e);
    }
}
 
开发者ID:reneweb,项目名称:react-native-tensorflow,代码行数:10,代码来源:RNTensorFlowGraphOperationsModule.java


示例6: output

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


示例7: outputList

import org.tensorflow.Operation; //导入依赖的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


示例8: outputListLength

import org.tensorflow.Operation; //导入依赖的package包/类
@ReactMethod
public void outputListLength(String id, String opName, String name, Promise promise) {
    try {
        Operation graphOperation = getGraphOperation(id, opName);
        promise.resolve(graphOperation.outputListLength(name));
    } catch (Exception e) {
        promise.reject(e);
    }
}
 
开发者ID:reneweb,项目名称:react-native-tensorflow,代码行数:10,代码来源:RNTensorFlowGraphOperationsModule.java


示例9: type

import org.tensorflow.Operation; //导入依赖的package包/类
@ReactMethod
public void type(String id, String opName, Promise promise) {
    try {
        Operation graphOperation = getGraphOperation(id, opName);
        promise.resolve(graphOperation.type());
    } catch (Exception e) {
        promise.reject(e);
    }
}
 
开发者ID:reneweb,项目名称:react-native-tensorflow,代码行数:10,代码来源:RNTensorFlowGraphOperationsModule.java


示例10: create

import org.tensorflow.Operation; //导入依赖的package包/类
/**
 * Initializes a native TensorFlow session for classifying images.
 *
 * @param assetManager The asset manager to be used to load assets.
 * @param modelFilename The filepath of the model GraphDef protocol buffer.
 * @param locationFilename The filepath of label file for classes.
 * @param inputSize The input size. A square image of inputSize x inputSize is assumed.
 * @param imageMean The assumed mean of the image values.
 * @param imageStd The assumed std of the image values.
 * @param inputName The label of the image input node.
 * @param outputName The label of the output node.
 */
public static Classifier create(
    final AssetManager assetManager,
    final String modelFilename,
    final String locationFilename,
    final int imageMean,
    final float imageStd,
    final String inputName,
    final String outputLocationsName,
    final String outputScoresName) {
  final TensorFlowMultiBoxDetector d = new TensorFlowMultiBoxDetector();

  d.inferenceInterface = new TensorFlowInferenceInterface(assetManager, modelFilename);

  final Graph g = d.inferenceInterface.graph();

  d.inputName = inputName;
  // The inputName node has a shape of [N, H, W, C], where
  // N is the batch size
  // H = W are the height and width
  // C is the number of channels (3 for our purposes - RGB)
  final Operation inputOp = g.operation(inputName);
  if (inputOp == null) {
    throw new RuntimeException("Failed to find input Node '" + inputName + "'");
  }
  d.inputSize = (int) inputOp.output(0).shape().size(1);
  d.imageMean = imageMean;
  d.imageStd = imageStd;
  // The outputScoresName node has a shape of [N, NumLocations], where N
  // is the batch size.
  final Operation outputOp = g.operation(outputScoresName);
  if (outputOp == null) {
    throw new RuntimeException("Failed to find output Node '" + outputScoresName + "'");
  }
  d.numLocations = (int) outputOp.output(0).shape().size(1);

  d.boxPriors = new float[d.numLocations * 8];

  try {
    d.loadCoderOptions(assetManager, locationFilename, d.boxPriors);
  } catch (final IOException e) {
    throw new RuntimeException("Error initializing box priors from " + locationFilename);
  }

  // Pre-allocate buffers.
  d.outputNames = new String[] {outputLocationsName, outputScoresName};
  d.intValues = new int[d.inputSize * d.inputSize];
  d.floatValues = new float[d.inputSize * d.inputSize * 3];
  d.outputScores = new float[d.numLocations];
  d.outputLocations = new float[d.numLocations * 4];

  return d;
}
 
开发者ID:apacha,项目名称:TensorflowAndroidDemo,代码行数:65,代码来源:TensorFlowMultiBoxDetector.java


示例11: getGraphOperation

import org.tensorflow.Operation; //导入依赖的package包/类
private Operation getGraphOperation(String id, String name) {
    return getReactApplicationContext().getNativeModule(RNTensorFlowGraphModule.class).getOperation(id, name);
}
 
开发者ID:reneweb,项目名称:react-native-tensorflow,代码行数:4,代码来源:RNTensorFlowGraphOperationsModule.java


示例12: loadNetwork

import org.tensorflow.Operation; //导入依赖的package包/类
@Override
    public void loadNetwork(File f) throws IOException {
        if (f == null) {
            throw new IOException("null file");
        }
        try {
            setFilename(f.toString());
            setNettype("TensorFlow");
            setNetname(f.getName());
            graphDef = Files.readAllBytes(Paths.get(f.getAbsolutePath())); // "tensorflow_inception_graph.pb"
            executionGraph = new Graph();
            executionGraph.importGraphDef(graphDef);
            Iterator<Operation> itr = executionGraph.operations();
            StringBuilder b = new StringBuilder("TensorFlow Graph: \n");
            int opnum = 0;
            ioLayers.clear();
            while (itr.hasNext()) {
                Operation o = itr.next();
                final String s = o.toString().toLowerCase();
//                if(s.contains("input") || s.contains("output") || s.contains("placeholder")){
                if (s.contains("input") || s.contains("placeholder") || s.contains("output")) {  // find input placeholder & output
//                    int numOutputs = o.numOutputs();
                    b.append("********** ");
                    ioLayers.add(s);
//                    for (int onum = 0; onum < numOutputs; onum++) {
//                        Output output = o.output(onum);
//                        Shape shape = output.shape();
//                        int numDimensions = shape.numDimensions();
//                        for (int dimidx = 0; dimidx < numDimensions; dimidx++) {
//                            long dim = shape.size(dimidx);
//                        }
//                    }
//                    int inputLength=o.inputListLength("");
                }
                b.append(opnum++ + ": " + o.toString() + "\n");
            }
            log.info(b.toString());
        } catch (Exception e) {
            log.warning(e.toString());
            e.printStackTrace();
        }
    }
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:43,代码来源:DavisCNNTensorFlow.java


示例13: create

import org.tensorflow.Operation; //导入依赖的package包/类
/**
 * Initializes a native TensorFlow session for classifying images.
 *
 * @param assetManager The asset manager to be used to load assets.
 * @param modelFilename The filepath of the model GraphDef protocol buffer.
 * @param locationFilename The filepath of label file for classes.
 * @param inputSize The input size. A square image of inputSize x inputSize is assumed.
 * @param imageMean The assumed mean of the image values.
 * @param imageStd The assumed std of the image values.
 * @param inputName The label of the image input node.
 * @param outputName The label of the output node.
 */
public static Classifier create(
    final AssetManager assetManager,
    final String modelFilename,
    final String locationFilename,
    final int imageMean,
    final float imageStd,
    final String inputName,
    final String outputLocationsName,
    final String outputScoresName) {
  final TensorFlowMultiBoxDetector d = new TensorFlowMultiBoxDetector();

  d.inferenceInterface = new TensorFlowInferenceInterface();
  if (d.inferenceInterface.initializeTensorFlow(assetManager, modelFilename) != 0) {
    throw new RuntimeException("TF initialization failed");
  }

  final Graph g = d.inferenceInterface.graph();

  d.inputName = inputName;
  // The inputName node has a shape of [N, H, W, C], where
  // N is the batch size
  // H = W are the height and width
  // C is the number of channels (3 for our purposes - RGB)
  final Operation inputOp = g.operation(inputName);
  if (inputOp == null) {
    throw new RuntimeException("Failed to find input Node '" + inputName + "'");
  }
  d.inputSize = (int) inputOp.output(0).shape().size(1);
  d.imageMean = imageMean;
  d.imageStd = imageStd;
  // The outputScoresName node has a shape of [N, NumLocations], where N
  // is the batch size.
  final Operation outputOp = g.operation(outputScoresName);
  if (outputOp == null) {
    throw new RuntimeException("Failed to find output Node '" + outputScoresName + "'");
  }
  d.numLocations = (int) outputOp.output(0).shape().size(1);

  d.boxPriors = new float[d.numLocations * 8];

  try {
    d.loadCoderOptions(assetManager, locationFilename, d.boxPriors);
  } catch (final IOException e) {
    throw new RuntimeException("Error initializing box priors from " + locationFilename);
  }

  // Pre-allocate buffers.
  d.outputNames = new String[] {outputLocationsName, outputScoresName};
  d.intValues = new int[d.inputSize * d.inputSize];
  d.floatValues = new float[d.inputSize * d.inputSize * 3];
  d.outputScores = new float[d.numLocations];
  d.outputLocations = new float[d.numLocations * 4];

  return d;
}
 
开发者ID:jxtz518,项目名称:Tensorflow_Andriod_With_Audio_Output,代码行数:68,代码来源:TensorFlowMultiBoxDetector.java


示例14: ensureDataField

import org.tensorflow.Operation; //导入依赖的package包/类
public DataField ensureDataField(SavedModel savedModel, NodeDef placeholder){

		if(!("Placeholder").equals(placeholder.getOp())){
			throw new IllegalArgumentException(placeholder.getName());
		}

		FieldName name = FieldName.create(placeholder.getName());

		DataField dataField = getDataField(name);
		if(dataField == null){
			Operation operation = savedModel.getOperation(placeholder.getName());

			Output output = operation.output(0);

			dataField = createDataField(name, TypeUtil.getOpType(output), TypeUtil.getDataType(output));
		}

		return dataField;
	}
 
开发者ID:jpmml,项目名称:jpmml-tensorflow,代码行数:20,代码来源:TensorFlowEncoder.java


示例15: createContinuousFeature

import org.tensorflow.Operation; //导入依赖的package包/类
public ContinuousFeature createContinuousFeature(SavedModel savedModel, NodeDef placeholder){
	NodeDef cast = null;

	if(("Cast").equals(placeholder.getOp())){
		cast = placeholder;
		placeholder = savedModel.getNodeDef(placeholder.getInput(0));
	}

	DataField dataField = ensureContinuousDataField(savedModel, placeholder);

	ContinuousFeature result = new ContinuousFeature(this, dataField);

	if(cast != null){
		Operation operation = savedModel.getOperation(cast.getName());

		Output output = operation.output(0);

		result = result.toContinuousFeature(TypeUtil.getDataType(output));
	}

	return result;
}
 
开发者ID:jpmml,项目名称:jpmml-tensorflow,代码行数:23,代码来源:TensorFlowEncoder.java


示例16: getOperation

import org.tensorflow.Operation; //导入依赖的package包/类
public Operation getOperation(String name){
	Graph graph = getGraph();

	return graph.operation(name);
}
 
开发者ID:jpmml,项目名称:jpmml-tensorflow,代码行数:6,代码来源:SavedModel.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MultiSearchRequest类代码示例发布时间:2022-05-21
下一篇:
Java QParser类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap