Jave tf record writer

6 Jave code examples are found related to " tf record writer". You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.
Example 1
Source File: TFRecordWriter.java    From OpenLabeler with Apache License 2.0 5 votes vote down vote up
private byte[] toInt32LE(int data) {
  byte[] buff = new byte[4];
  ByteBuffer bb = ByteBuffer.wrap(buff);
  bb.order(ByteOrder.LITTLE_ENDIAN);
  bb.putInt(data);
  return buff;
}
 
Example 2
Source File: TFRecordWriter.java    From OpenLabeler with Apache License 2.0 5 votes vote down vote up
public void write(byte[] record, int offset, int length) throws IOException {
  /**
   * TFRecord format:
   * uint64 length
   * uint32 masked_crc32_of_length
   * byte   data[length]
   * uint32 masked_crc32_of_data
   */
  byte[] len = toInt64LE(length);
  output.write(len);
  output.write(toInt32LE(Crc32C.maskedCrc32c(len)));
  output.write(record, offset, length);
  output.write(toInt32LE(Crc32C.maskedCrc32c(record, offset, length)));
}
 
Example 3
Source File: TFRecordWriter.java    From OpenLabeler with Apache License 2.0 5 votes vote down vote up
private byte[] toInt64LE(long data) {
  byte[] buff = new byte[8];
  ByteBuffer bb = ByteBuffer.wrap(buff);
  bb.order(ByteOrder.LITTLE_ENDIAN);
  bb.putLong(data);
  return buff;
}
 
Example 4
Source File: TFRecordWriter.java    From OpenLabeler with Apache License 2.0 4 votes vote down vote up
public TFRecordWriter(DataOutput output) {
  this.output = output;
}
 
Example 5
Source File: TFRecordIO.java    From beam with Apache License 2.0 4 votes vote down vote up
private TFRecordWriter(WriteOperation<Void, byte[]> writeOperation) {
  super(writeOperation, MimeTypes.BINARY);
}
 
Example 6
Source File: TFRecordIO.java    From beam with Apache License 2.0 4 votes vote down vote up
@Override
public Writer<Void, byte[]> createWriter() throws Exception {
  return new TFRecordWriter(this);
}