org.tensorflow.op.sparse.SparseSegmentMeanWithNumSegments Maven / Gradle / Ivy
/* Copyright 2018 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=======================================================================*/
// This class has been generated, DO NOT EDIT!
package org.tensorflow.op.sparse;
import org.tensorflow.Operand;
import org.tensorflow.Operation;
import org.tensorflow.OperationBuilder;
import org.tensorflow.Output;
import org.tensorflow.op.PrimitiveOp;
import org.tensorflow.op.Scope;
import org.tensorflow.op.annotation.Operator;
/**
* Computes the mean along sparse segments of a tensor.
*
* Like `SparseSegmentMean`, but allows missing ids in `segment_ids`. If an id is
* misisng, the `output` tensor at that position will be zeroed.
*
* Read
* [the section on segmentation](https://tensorflow.org/api_docs/python/tf/math#Segmentation)
* for an explanation of segments.
*
* @param data type for {@code output()} output
*/
@Operator(group = "sparse")
public final class SparseSegmentMeanWithNumSegments extends PrimitiveOp implements Operand {
/**
* Factory method to create a class wrapping a new SparseSegmentMeanWithNumSegments operation.
*
* @param scope current scope
* @param data
* @param indices A 1-D tensor. Has same rank as `segment_ids`.
* @param segmentIds A 1-D tensor. Values should be sorted and can be repeated.
* @param numSegments Should equal the number of distinct segment IDs.
* @return a new instance of SparseSegmentMeanWithNumSegments
*/
public static SparseSegmentMeanWithNumSegments create(Scope scope, Operand data, Operand indices, Operand segmentIds, Operand numSegments) {
OperationBuilder opBuilder = scope.env().opBuilder("SparseSegmentMeanWithNumSegments", scope.makeOpName("SparseSegmentMeanWithNumSegments"));
opBuilder.addInput(data.asOutput());
opBuilder.addInput(indices.asOutput());
opBuilder.addInput(segmentIds.asOutput());
opBuilder.addInput(numSegments.asOutput());
opBuilder = scope.applyControlDependencies(opBuilder);
return new SparseSegmentMeanWithNumSegments(opBuilder.build());
}
/**
* Has same shape as data, except for dimension 0 which has size
* `num_segments`.
*/
public Output output() {
return output;
}
@Override
public Output asOutput() {
return output;
}
private Output output;
private SparseSegmentMeanWithNumSegments(Operation operation) {
super(operation);
int outputIdx = 0;
output = operation.output(outputIdx++);
}
}