Edit: 基本上我需要以下方面的建议:
给定 100 张图像 (256,256,3) 的集合,分为 4 个四边形 (128,128,3),如何将其传递给需要 4 个输入(4 个四边形)的模型?
Edit 2:我已经对更具体的脚本进行了更多的修改。正如我最初的想法,它是一个 x 输入的列表,这些输入是具有任何定义形状的数组。但我已经修改了我的代码来做到这一点,但它仍然不起作用。这是控制台的转储,包括 trainX len、trainX[0] 形状和预期输入的打印:
Edit 3: 请务必检查您的outputs以及我们的inputs.
Using TensorFlow backend.
Start Fit - round: 0
trainX length: 4
trainX[0] shape: (92, 128, 128, 3)
Expected Model inputs: [<tf.Tensor 'input_1:0' shape=(?, 128, 128, 3) dtype=float32>, <tf.Tensor 'input_2:0' shape=(?, 128, 128, 3) dtype=float32>, <tf.Tensor 'input_3:0' shape=(?, 128, 128, 3) dtype=float32>, <tf.Tensor 'input_4:0' shape=(?, 128, 128, 3) dtype=float32>]
Traceback (most recent call last):
File "D:\Func\FuncTest.py", line 193, in <module>
verbose = 1)
File "D:\FtPrnt\Keras\lib\site-packages\keras\engine\training.py", line 1574, in fit
batch_size=batch_size)
File "D:\FtPrnt\Keras\lib\site-packages\keras\engine\training.py", line 1411, in _standardize_user_data
exception_prefix='target')
File "D:\FtPrnt\Keras\lib\site-packages\keras\engine\training.py", line 88, in _standardize_input_data
'...')
ValueError: Error when checking model target: the list of Numpy arrays that you are passing to your model is not the size the model expected. Expected to see 1 array(s), but instead got the following list of 4 arrays: [array([[[ 255., 255., 255., ..., 255., 255., 255.],
[ 255., 255., 255., ..., 255., 255., 255.],
[ 255., 255., 255., ..., 255., 255., 255.],
...,
[ 0....
我正在涉足函数式 API 并尝试使用多个输入。
但我一直无法让它正常工作。
我已经使用单个输入测试了我的模型,它工作正常,但添加多个输入和串联失败。
我的测试是加载单个图像,将其分成四部分,然后通过 4 个输入将其推送到网络中。
我几乎尝试了我能想到的列表和 numpy 数组的所有组合,但每次我都得到了。
我的理解是,我应该提供一个(四个)输入的列表,它们是形状为(samples,img_dim_x,img_dim_y,img_layers)的数组。但每当我尝试这样做时,它都不起作用。
环顾四周后,我在某个地方看到该数组应该是样本数。所以我尝试了,但也失败了。我当前的代码 https://gist.github.com/anonymous/3388645f4aeed64022d57e04b99b27c8遵循这个想法,提供一个具有一定长度样本的列表,其中包含一个形状为 (inputs, img_dim_x, img_dim_y, img_layers) 的数组