Esempio n. 1
0
def test_json_serialize_dict_with_numpy():
    data = {'tensor1': np.asarray([1, 2, 3]), 'tensor2': np.asarray([4, 5, 6])}
    serialized = tf_json_serializer(data)
    # deserialize again for assertion, since dict order is not guaranteed
    deserialized = json.loads(serialized)
    assert deserialized == {'tensor1': [1, 2, 3], 'tensor2': [4, 5, 6]}
Esempio n. 2
0
def test_json_serialize_numpy():
    data = np.asarray([[1, 2, 3], [4, 5, 6]])
    assert tf_json_serializer(data) == '[[1, 2, 3], [4, 5, 6]]'
Esempio n. 3
0
def test_json_serialize_dict():
    data = {'tensor1': [1, 2, 3], 'tensor2': [4, 5, 6]}
    serialized = tf_json_serializer(data)
    # deserialize again for assertion, since dict order is not guaranteed
    deserialized = json.loads(serialized)
    assert deserialized == data