我的模型是2个不同的keras模型的集合,这些模型连接到相同的输入层,合并后具有2个输出层。 两种模型都是经过预训练的,我正在尝试创建并行架构。 我的架构是: `
define('PACKAGE_PRODUCT_ID', 1010);
add_action('woocommerce_payment_complete', 'order_splitter', 100, 1);
function order_splitter($order_id){
$completed_order = new WC_Order($order_id);
$item_splitted = false;
$address = array(
'first_name' => $completed_order->get_billing_first_name(),
'last_name' => $completed_order->get_billing_last_name(),
'company' => '',
'email' => $completed_order->get_billing_email(),
'phone' => $completed_order->get_billing_phone(),
'address_1' => $completed_order->get_billing_address_1(),
'address_2' => $completed_order->get_billing_address_2(),
'city' => $completed_order->get_billing_city(),
'state' => $completed_order->get_billing_state(),
'postcode' => $completed_order->get_billing_postcode(),
'country' => $completed_order->get_billing_country()
);
foreach($completed_order->get_items() as $item){
if (!$item_splitted && $item->get_product_id() === PACKAGE_PRODUCT_ID) {
//create new order
$new_order_args = array(
'customer_id' => $completed_order->get_customer_id(),
'status' => 'wc-pending',
);
$new_order = wc_create_order($new_order_args);
$product_to_add = wc_get_product(PACKAGE_PRODUCT_ID);
$new_order->add_product($product_to_add, 1, array());
$new_order->set_address($address, 'billing');
$new_order->set_address($address, 'shipping');
$new_order->update_status('wc-processing');
$new_order->add_order_note('This order created automatically');
$new_order->save();
$completed_order->remove_item($item->get_id());
$item_splitted = true;
} else if ($item_splitted && $item['product_id'] === PACKAGE_PRODUCT_ID){
# This will ensure every 2 products are splitted (skipping the 2nd one)
$item_splitted = false;
continue;
}
}
}
`
模型被编译,我也可以做出预测,但是当我保存并尝试重新加载它时,我得到了:
model_input = Input(shape=(224,224,3), name="model_input")
gender_model_copy.layers.pop(0)
color_model_copy.layers.pop(0)
color_model_ens1 = color_model_copy(model_input)
gender_model_ens1 = gender_model_copy(model_input)
model_f = Model(input=[model_input], output=[color_model_ens1,gender_model_ens1])
model_f.save('path')
完整跟踪:Github gist link。
我有一个使用ValueError: Invalid input_shape argument (None, 224, 224, 3): model has 0 tensor inputs.
添加的自定义图层
custom_objects={'Scale':Scale()}
中的参数
我的keras版本是2.2.5,而tensorflow版本是1.15
答案 0 :(得分:0)
如果您重命名其中一个图层,则可能会出现问题。停止重命名。