Как преобразовать tf- js в модель тензорного потока pb - PullRequest
0 голосов
/ 05 мая 2020

Я пытаюсь загрузить tf js классификатор токсичности для загрузки в Python

Я пробовал tf js -конвертер это способом (я загрузил файлы json и сегментов)

tensorflowjs_converter --input_format=tfjs_layers_model --output_format=keras_saved_model model.json convert.h5

Я пробовал оба параметра в разделе JavaScript -to- Python из tf js -конвертера, это поднимает:

2020-05-05 01:14:03.148408: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 2300000000 Hz
2020-05-05 01:14:03.148659: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x1c98840 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2020-05-05 01:14:03.148696: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): Host, Default Version
Traceback (most recent call last):
  File "/usr/local/bin/tensorflowjs_converter", line 8, in <module>
    sys.exit(pip_main())
  File "/usr/local/lib/python3.6/dist-packages/tensorflowjs/converters/converter.py", line 671, in pip_main
    main([' '.join(sys.argv[1:])])
  File "/usr/local/lib/python3.6/dist-packages/tensorflowjs/converters/converter.py", line 675, in main
    convert(argv[0].split(' '))
  File "/usr/local/lib/python3.6/dist-packages/tensorflowjs/converters/converter.py", line 636, in convert
    args.output_path)
  File "/usr/local/lib/python3.6/dist-packages/tensorflowjs/converters/converter.py", line 264, in dispatch_tensorflowjs_to_keras_saved_model_conversion
    model = keras_tfjs_loader.load_keras_model(config_json_path)
  File "/usr/local/lib/python3.6/dist-packages/tensorflowjs/converters/keras_tfjs_loader.py", line 217, in load_keras_model
    use_unique_name_scope=use_unique_name_scope)
  File "/usr/local/lib/python3.6/dist-packages/tensorflowjs/converters/keras_tfjs_loader.py", line 64, in _deserialize_keras_model
    model = tf.keras.models.model_from_json(json.dumps(model_topology_json))
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/keras/saving/model_config.py", line 96, in model_from_json
    return deserialize(config, custom_objects=custom_objects)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/keras/layers/serialization.py", line 98, in deserialize
    layer_class_name = config['class_name']
KeyError: 'class_name'

Еще одно репо, которое я пробовал: tf js -to-tf

И следующее: tfjs_graph_converter model.json convert/model.pb

Повышает:

TensorFlow.js Graph Model Converter

Graph model:    model.json
Output:         convert/model.pb
Target format:  tf_frozen_model

Converting.... Traceback (most recent call last):
  File "/usr/local/bin/tfjs_graph_converter", line 8, in <module>
    sys.exit(pip_main())
  File "/usr/local/lib/python3.6/dist-packages/tfjs_graph_converter/converter.py", line 127, in pip_main
    main([' '.join(sys.argv[1:])])
  File "/usr/local/lib/python3.6/dist-packages/tfjs_graph_converter/converter.py", line 137, in main
    convert(argv[0].split(' '))
  File "/usr/local/lib/python3.6/dist-packages/tfjs_graph_converter/converter.py", line 107, in convert
    api.graph_model_to_frozen_graph(args.input_path, args.output_path)
  File "/usr/local/lib/python3.6/dist-packages/tfjs_graph_converter/api.py", line 237, in graph_model_to_frozen_graph
    graph = load_graph_model(model_dir)
  File "/usr/local/lib/python3.6/dist-packages/tfjs_graph_converter/api.py", line 224, in load_graph_model
    return _convert_graph_model_to_graph(model_json, model_path)
  File "/usr/local/lib/python3.6/dist-packages/tfjs_graph_converter/api.py", line 202, in _convert_graph_model_to_graph
    graph_def = _convert_graph_def(topology)
  File "/usr/local/lib/python3.6/dist-packages/tfjs_graph_converter/api.py", line 139, in _convert_graph_def
    message_dict = _convert_attr_values(message_dict)
  File "/usr/local/lib/python3.6/dist-packages/tfjs_graph_converter/api.py", line 124, in _convert_attr_values
    _convert_string_attrs(node)
  File "/usr/local/lib/python3.6/dist-packages/tfjs_graph_converter/api.py", line 72, in _convert_string_attrs
    attrs = _find_if_has_key(node[attr_key], key=str_key, of_type=list)
KeyError: 'attr'

Любая помощь по этому поводу приветствуется или предложения о том, как загрузить модель tf js в python:)

...