tensorflow / tensorflow/java

TF Python producing malformed JSON for numpy style arrays.

未关闭
#444 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
Java
星标
928
派生
227
PR 合并指标
30 天内没有已合并 PR

描述

TF Python serializes numpy style arrays (e.g. Java NdArray) in the format 'normalizer': array([[0.2, 0.2], [0.1, 0.3]], dtype=float32)'.
This is not standard JSON, and tools, like GSON, throw a MalformedJsonException when trying to parse this.

The issue is how to best handle this in TF Java.

I have looked at GSON using customized TypeAdapter and Serilaizers/Deserializers, but I cannot get past the low level parsing throwing the MalformedJsonException. Right now I think my only alternative is to write a pre-parser to convert the array() format string to a wellformed JSON string.
For example, for the above example:

         {
             'normalizer': {
                " '_ArraySize_' = [1,2],    
                " '_ArrayData_' =  [[0.2, 0.2], [0.1, 0.3]], 
                " '_ArrayType_' = 'float32' 
              }
          }

_ArraySize_ is the array's shape and _ArrayType_ is the datatype for the NdArray.
This format is taken from OpenJData

Also, once we settle on a way to do this, should the NdArray package be modified to include serialize/deserialize methods.
What about compatibility with TF Python?

Any suggestions?

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先复现 issue 中展示的 TF Python 序列化,并跟踪 TF Java NdArray 数据如何进入 GSON 解析。将提议的数组表示形式与 OpenJData 格式进行比较,并定义预期的兼容性行为;当格式以及序列化/反序列化的职责归属达成一致,且不再生成格式错误的 JSON 时,即视为完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
java, python, tensorflow
领域
api, backend
Issue 类型
缺陷
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
需要澄清
新手友好度
22/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。