TF Python producing malformed JSON for numpy style arrays.
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Java
- Sterne
- 928
- Forks
- 227
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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?
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, die im Issue gezeigte TF-Python-Serialisierung zu reproduzieren und nachzuverfolgen, wie TF-Java-NdArray-Daten das GSON-Parsing erreichen. Vergleiche die vorgeschlagene Array-Darstellung mit dem OpenJData-Format und definiere das erwartete Kompatibilitätsverhalten; als erledigt gilt die Aufgabe, wenn Format und Zuständigkeit für Serialisierung/Deserialisierung abgestimmt sind und kein fehlerhaftes JSON mehr erzeugt wird.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- java, python, tensorflow
- Bereich
- api, backend
- Issue-Typ
- Bug
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 22/100