keras-model-to-cpp icon indicating copy to clipboard operation
keras-model-to-cpp copied to clipboard

Issue Dumping network to dat file

Open MaajidKhan opened this issue 5 years ago • 1 comments

Hey, I have issue while dumping the network into dat file. Basically, 2nd step : 2. Dump network to dat file python dump_to_cpp.py -a arch.json -w weights.h5 -o dumped_nn.dat.

while, I run this script dump_to_cpp.py , it throws an error:

Using TensorFlow backend. Read architecture from arch.json Read weights from weights.h5 Writing to converted_to_cpp.dat 0 name Traceback (most recent call last): File "dump_to_cpp.py", line 36, in fout.write('layer ' + str(ind) + ' ' + l['class_name'] + '\n') TypeError: string indices must be integers

The issue is, l should have been of data type 'list' but in our case it is a 'string'.

can you please rectify this issue and provide a working solution.

MaajidKhan avatar May 05 '20 17:05 MaajidKhan

Hey, I have issue while dumping the network into dat file. Basically, 2nd step : 2. Dump network to dat file python dump_to_cpp.py -a arch.json -w weights.h5 -o dumped_nn.dat.

while, I run this script dump_to_cpp.py , it throws an error:

Using TensorFlow backend. Read architecture from arch.json Read weights from weights.h5 Writing to converted_to_cpp.dat 0 name Traceback (most recent call last): File "dump_to_cpp.py", line 36, in fout.write('layer ' + str(ind) + ' ' + l['class_name'] + '\n') TypeError: string indices must be integers

The issue is, l should have been of data type 'list' but in our case it is a 'string'.

can you please rectify this issue and provide a working solution.

I think it is due to version difference, It can be solved by adding 'layers' in line 38 like this

for ind, l in enumerate(arch["config"]['layers']):

abdulwaheedsoudagar avatar Jul 28 '21 07:07 abdulwaheedsoudagar