Generated Java code for TensorFlow protocol buffers, providing type-safe access to TensorFlow's structured data formats including MetaGraphDef, ConfigProto, and other core TensorFlow data structures.
Event logging, debugging, and other utility data structures for TensorFlow operations monitoring and analysis. These types support model debugging, performance profiling, and execution monitoring.
Protocol buffer for logging events during model execution, including scalar summaries, histograms, and debugging information.
/**
* Protocol buffer for logging events during model execution
*/
class Event {
/** Get wall clock time as Unix timestamp */
double getWallTime();
/** Get training step number */
long getStep();
/** Get file version string */
String getFileVersion();
/** Get serialized graph definition */
ByteString getGraphDef();
/** Get summary data */
Summary getSummary();
/** Get log message */
LogMessage getLogMessage();
/** Get session log */
SessionLog getSessionLog();
/** Get tagged run metadata */
TaggedRunMetadata getTaggedRunMetadata();
/** Get metadata for debugging */
ByteString getMetaGraphDef();
/** Get which event type is set */
WhatCase getWhatCase();
/** Create a new builder for constructing Event */
static Builder newBuilder();
/** Builder for constructing Event instances */
static class Builder {
Builder setWallTime(double wallTime);
Builder setStep(long step);
Builder setFileVersion(String version);
Builder setGraphDef(ByteString graphDef);
Builder setSummary(Summary summary);
Builder setLogMessage(LogMessage logMessage);
Builder setSessionLog(SessionLog sessionLog);
Builder setTaggedRunMetadata(TaggedRunMetadata metadata);
Builder setMetaGraphDef(ByteString metaGraphDef);
Event build();
}
/** Enum indicating which event type is set */
enum WhatCase {
FILE_VERSION,
GRAPH_DEF,
SUMMARY,
LOG_MESSAGE,
SESSION_LOG,
TAGGED_RUN_METADATA,
META_GRAPH_DEF,
WHAT_NOT_SET
}
}Usage Examples:
import org.tensorflow.util.*;
import org.tensorflow.framework.*;
// Create a scalar summary event
Event scalarEvent = Event.newBuilder()
.setWallTime(System.currentTimeMillis() / 1000.0)
.setStep(1000)
.setSummary(Summary.newBuilder()
.addValue(Summary.Value.newBuilder()
.setTag("loss")
.setSimpleValue(0.25f)
.build())
.addValue(Summary.Value.newBuilder()
.setTag("accuracy")
.setSimpleValue(0.95f)
.build())
.build())
.build();
// Create a histogram summary event
Event histogramEvent = Event.newBuilder()
.setWallTime(System.currentTimeMillis() / 1000.0)
.setStep(1000)
.setSummary(Summary.newBuilder()
.addValue(Summary.Value.newBuilder()
.setTag("weights/layer1")
.setHisto(HistogramProto.newBuilder()
.setMin(-1.5)
.setMax(1.5)
.setNum(1000)
.setSum(0.0)
.setSumSquares(250.0)
.addBucketLimit(-1.0)
.addBucketLimit(0.0)
.addBucketLimit(1.0)
.addBucket(100)
.addBucket(800)
.addBucket(100)
.build())
.build())
.build())
.build();
// Create a graph definition event
Event graphEvent = Event.newBuilder()
.setWallTime(System.currentTimeMillis() / 1000.0)
.setStep(0)
.setGraphDef(myGraphDef.toByteString())
.build();Contains summary data for visualization and monitoring.
/**
* Summary data for TensorBoard visualization
*/
class Summary {
/** Get list of summary values */
List<Value> getValueList();
/** Create a new builder for constructing Summary */
static Builder newBuilder();
/** Builder for constructing Summary instances */
static class Builder {
Builder addValue(Value value);
Builder addAllValue(Iterable<Value> values);
Summary build();
}
/** Individual summary value */
static class Value {
/** Get value tag/name */
String getTag();
/** Get simple scalar value */
float getSimpleValue();
/** Get obsolete old-style scalar value */
@Deprecated
ByteString getObsoleteOldStyleHistogram();
/** Get image summary */
Image getImage();
/** Get histogram summary */
HistogramProto getHisto();
/** Get audio summary */
Audio getAudio();
/** Get tensor summary */
TensorProto getTensor();
/** Get which value type is set */
ValueCase getValueCase();
/** Create a new builder */
static Builder newBuilder();
/** Builder for Value instances */
static class Builder {
Builder setTag(String tag);
Builder setSimpleValue(float value);
Builder setImage(Image image);
Builder setHisto(HistogramProto histo);
Builder setAudio(Audio audio);
Builder setTensor(TensorProto tensor);
Value build();
}
enum ValueCase {
SIMPLE_VALUE,
OBSOLETE_OLD_STYLE_HISTOGRAM,
IMAGE,
HISTO,
AUDIO,
TENSOR,
VALUE_NOT_SET
}
}
}Histogram data for distribution visualization.
/**
* Histogram data for distribution visualization
*/
class HistogramProto {
/** Get minimum value */
double getMin();
/** Get maximum value */
double getMax();
/** Get number of values */
long getNum();
/** Get sum of all values */
double getSum();
/** Get sum of squares of all values */
double getSumSquares();
/** Get bucket limits (edges) */
List<Double> getBucketLimitList();
/** Get bucket counts */
List<Long> getBucketList();
/** Create a new builder */
static Builder newBuilder();
/** Builder for constructing HistogramProto instances */
static class Builder {
Builder setMin(double min);
Builder setMax(double max);
Builder setNum(long num);
Builder setSum(double sum);
Builder setSumSquares(double sumSquares);
Builder addBucketLimit(double limit);
Builder addBucket(long count);
HistogramProto build();
}
}Media summaries for visualization.
/**
* Image summary for visualization
*/
static class Image {
/** Get image height */
int getHeight();
/** Get image width */
int getWidth();
/** Get color space (1=grayscale, 2=grayscale+alpha, 3=RGB, 4=RGBA) */
int getColorspace();
/** Get encoded image data (PNG/JPEG) */
ByteString getEncodedImageString();
/** Create a new builder */
static Builder newBuilder();
static class Builder {
Builder setHeight(int height);
Builder setWidth(int width);
Builder setColorspace(int colorspace);
Builder setEncodedImageString(ByteString data);
Image build();
}
}
/**
* Audio summary for visualization
*/
static class Audio {
/** Get sample rate in Hz */
float getSampleRate();
/** Get number of channels */
long getNumChannels();
/** Get length in frames */
long getLengthFrames();
/** Get encoded audio data (WAV) */
ByteString getEncodedAudioString();
/** Get content type */
String getContentType();
/** Create a new builder */
static Builder newBuilder();
static class Builder {
Builder setSampleRate(float rate);
Builder setNumChannels(long channels);
Builder setLengthFrames(long frames);
Builder setEncodedAudioString(ByteString data);
Builder setContentType(String type);
Audio build();
}
}Log messages for debugging and monitoring.
/**
* Log message for debugging and monitoring
*/
class LogMessage {
/** Get log level */
Level getLevel();
/** Get log message text */
String getMessage();
/** Create a new builder */
static Builder newBuilder();
static class Builder {
Builder setLevel(Level level);
Builder setMessage(String message);
LogMessage build();
}
/** Log levels */
enum Level {
UNKNOWN,
DEBUG,
INFO,
WARN,
ERROR,
FATAL
}
}Session lifecycle logging.
/**
* Session lifecycle event logging
*/
class SessionLog {
/** Get session status */
SessionStatus getStatus();
/** Get checkpoint path if applicable */
String getCheckpointPath();
/** Get error message if failed */
String getMsg();
/** Create a new builder */
static Builder newBuilder();
static class Builder {
Builder setStatus(SessionStatus status);
Builder setCheckpointPath(String path);
Builder setMsg(String message);
SessionLog build();
}
/** Session status values */
enum SessionStatus {
STATUS_UNSPECIFIED,
START,
STOP,
CHECKPOINT
}
}Metadata from step execution with profiling information.
/**
* Tagged run metadata with profiling information
*/
class TaggedRunMetadata {
/** Get metadata tag */
String getTag();
/** Get run metadata */
ByteString getRunMetadata();
/** Create a new builder */
static Builder newBuilder();
static class Builder {
Builder setTag(String tag);
Builder setRunMetadata(ByteString metadata);
TaggedRunMetadata build();
}
}Utilities for saved model tensor slicing.
/**
* Metadata for saved tensor slices
*/
class SavedTensorSliceMeta {
/** Get tensor information */
List<SavedTensorSliceMeta.TensorSliceMetaData> getTensorList();
/** Get versions information */
VersionDef getVersions();
/** Metadata for individual tensor slices */
static class TensorSliceMetaData {
/** Get tensor name */
String getName();
/** Get tensor shape */
TensorShapeProto getShape();
/** Get tensor type */
DataType getType();
/** Get slice specifications */
List<TensorSliceProto> getSliceList();
}
}
/**
* Specification for tensor slice
*/
class TensorSliceProto {
/** Get extent specifications */
List<Extent> getExtentList();
/** Extent along one dimension */
static class Extent {
/** Check if extent has start position */
boolean hasStart();
/** Get start position */
long getStart();
/** Check if extent has length */
boolean hasLength();
/** Get length (or -1 for rest of dimension) */
long getLength();
}
}Usage Examples:
import org.tensorflow.util.*;
// Create training metrics summary
Summary trainingMetrics = Summary.newBuilder()
.addValue(Summary.Value.newBuilder()
.setTag("train/loss")
.setSimpleValue(0.123f)
.build())
.addValue(Summary.Value.newBuilder()
.setTag("train/accuracy")
.setSimpleValue(0.945f)
.build())
.addValue(Summary.Value.newBuilder()
.setTag("train/learning_rate")
.setSimpleValue(0.001f)
.build())
.build();
// Create image summary (e.g., for sample predictions)
Summary.Image imageSummary = Summary.Image.newBuilder()
.setHeight(224)
.setWidth(224)
.setColorspace(3) // RGB
.setEncodedImageString(ByteString.copyFrom(pngImageBytes))
.build();
Summary imageEvent = Summary.newBuilder()
.addValue(Summary.Value.newBuilder()
.setTag("predictions/sample_image")
.setImage(imageSummary)
.build())
.build();
// Create session lifecycle log
SessionLog startLog = SessionLog.newBuilder()
.setStatus(SessionLog.SessionStatus.START)
.setMsg("Training session started")
.build();
Event sessionEvent = Event.newBuilder()
.setWallTime(System.currentTimeMillis() / 1000.0)
.setStep(0)
.setSessionLog(startLog)
.build();Install with Tessl CLI
npx tessl i tessl/maven-org-tensorflow--proto