Skip to content

Cannot convert model_dsd_fft_1024.pkl Model from PKL to JSON #20

@acharya1981

Description

@acharya1981

I'm trying to convert above PKL file to JSON but gives error before converting. So as to import KERAS Model in MATLAB.

using this code in Python:

Convert a pkl file into json file
'''
import sys
import os
import pickle as pkl
import json

def convert_dict_to_json(file_path):
with open(file_path, 'rb') as fpkl, open('%s.json' % file_path, 'w') as fjson:
data = pkl.load(fpkl)
json.dump(data, fjson, ensure_ascii=False, sort_keys=True, indent=4)

And the error is:

File "C:\Python27\lib\json\encoder.py", line 184, in default
raise TypeError(repr(o) + " is not JSON serializable")
TypeError: array([[[[ 1.4630563e+00, 1.2371855e+00, 9.0325326e-01, ...,
2.0356092e-03, -9.0812740e-04, -8.2676094e-03]]],

Can You Provide converted .JSON file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions