@Override
    public TensorProto serialize() {
        TensorProto.Builder builder = TensorProto.newBuilder();

        builder.setVersion(CURRENT_VERSION);
        builder.setClassName(DenseVector.class.getName());

        DenseTensorProto.Builder dataBuilder = DenseTensorProto.newBuilder();
        dataBuilder.addAllDimensions(Arrays.stream(shape).boxed().collect(Collectors.toList()));
        ByteBuffer buffer = ByteBuffer.allocate(elements.length * 8).order(ByteOrder.LITTLE_ENDIAN);
        DoubleBuffer doubleBuffer = buffer.asDoubleBuffer();
        doubleBuffer.put(elements);
        doubleBuffer.rewind();
        dataBuilder.setValues(ByteString.copyFrom(buffer));
        builder.setSerializedData(Any.pack(dataBuilder.build()));

        return builder.build();
    }
@Test
    public void serializationTest() {
        DenseVector a = generateVectorA();
        TensorProto proto = a.serialize();
        Tensor deser = Tensor.deserialize(proto);
        assertEquals(a,deser);
    }