#keras #tf.keras #tensorflow1.15
Вопрос:
Я пытаюсь добавить функцию (забаву) к выходным данным моей модели keras (y1,y2), чтобы создать другую модель keras
Это код, приводящий к вышеупомянутой ошибке:
i = tf.constant(0)
output2 = tf.Variable([])
def loop_body(i, output2):
x = fun(y1[i],y2[i])
output2 = tf.concat([output2, x], 0)
return i 1, output2
c = lambda i, output2: i < 4
index2, output2 = tf.while_loop(c, loop_body, [i, output2], shape_invariants=[i.get_shape(), tf.TensorShape([None])])
return tf.keras.Model(inputs, output2)
Модель была y1,y2 соответствует y1,y2 в этой функции : https://github.com/qqwweee/keras-yolo3/blob/master/yolo3/model.py#L89
Я повторяю цикл более 4 раз, предполагая, что у меня будет 4 выборки в размере входного пакета при запуске predict_on_batch на этой модели. Мне все еще нужно придумать, как поместить заполнитель для y1.shape[0] или y2.shape[0]
Ниже приведены полные журналы ошибок:
return tf.keras.Model(inputs, output2)
File "my_path.venvlibsite-packagestensorflow_corepythonkerasenginetraining.py", line 147, in __init__
super(Model, self).__init__(*args, **kwargs)
File "my_path.venvlibsite-packagestensorflow_corepythonkerasenginenetwork.py", line 164, in __init__
self._init_graph_network(*args, **kwargs)
File "my_path.venvlibsite-packagestensorflow_corepythontrainingtrackingbase.py", line 457, in _method_wrapper
result = method(self, *args, **kwargs)
File "my_path.venvlibsite-packagestensorflow_corepythonkerasenginenetwork.py", line 267, in _init_graph_network
base_layer_utils.create_keras_history(self._nested_outputs)
File "my_path.venvlibsite-packagestensorflow_corepythonkerasenginebase_layer_utils.py", line 184, in create_keras_history
_, created_layers = _create_keras_history_helper(tensors, set(), [])
File "my_path.venvlibsite-packagestensorflow_corepythonkerasenginebase_layer_utils.py", line 231, in _create_keras_history_helper
layer_inputs, processed_ops, created_layers)
File "my_path.venvlibsite-packagestensorflow_corepythonkerasenginebase_layer_utils.py", line 231, in _create_keras_history_helper
layer_inputs, processed_ops, created_layers)
File "my_path.venvlibsite-packagestensorflow_corepythonkerasenginebase_layer_utils.py", line 231, in _create_keras_history_helper
layer_inputs, processed_ops, created_layers)
[Previous line repeated 946 more times]
File "my_path.venvlibsite-packagestensorflow_corepythonkerasenginebase_layer_utils.py", line 229, in _create_keras_history_helper
constants[i] = backend.function([], op_input)([])
File "my_path.venvlibsite-packagestensorflow_corepythonkerasbackend.py", line 3678, in function
return GraphExecutionFunction(inputs, outputs, updates=updates, **kwargs)
File "my_path.venvlibsite-packagestensorflow_corepythonkerasbackend.py", line 3339, in __init__
self.updates_op = control_flow_ops.group(*updates_ops)
File "my_path.venvlibsite-packagestensorflow_corepythonopscontrol_flow_ops.py", line 2878, in group
return no_op(name=name)
File "my_path.venvlibsite-packagestensorflow_corepythonopsgen_control_flow_ops.py", line 584, in no_op
"NoOp", name=name)
File "my_path.venvlibsite-packagestensorflow_corepythonframeworkop_def_library.py", line 794, in _apply_op_helper
op_def=op_def)
File "my_path.venvlibsite-packagestensorflow_corepythonutildeprecation.py", line 480, in new_func
named_args = tf_inspect.getcallargs(func, *args, **kwargs)
File "my_path.venvlibsite-packagestensorflow_corepythonutiltf_inspect.py", line 278, in getcallargs
argspec = getfullargspec(func)
File "my_path.venvlibsite-packagestensorflow_corepythonutiltf_inspect.py", line 257, in getfullargspec
return _getfullargspec(target)
File "my_user.pyenvpyenv-winversions3.7.8libinspect.py", line 1132, in getfullargspec
raise TypeError('unsupported callable') from ex