前提・実現したいこと
Pythonで低解像度画像を高解像度化するモデルを生成しています。
2つの流れで生成された画像を1つに組み合わせて、畳み込みを行う際にエラーが発生しました。
入力画像のサイズは16×16のグレー画像で、出力では128×128にしたいです。
参考にした論文:"https://arxiv.org/pdf/1603.07235.pdf"
今年の春からプログラミングを始めた初心者です。質問内容以外にも指摘してくださるとありがたいです。
よろしくお願いします。
### 発生している問題・エラーメッセージ Layer conv2d_1 was called with an input that isn't a symbolic tensor. Received type: <class 'keras.layers.merge.Concatenate'>. Full input: [<keras.layers.merge.Concatenate object at 0x00000168E176FB70>]. All inputs to the layer should be tensors.
###Traceback
Traceback (most recent call last): File "c:\program files (x86)\microsoft visual studio\2017\community\common7\ide\extensions\microsoft\python\core\ptvsd_launcher.py", line 119, in <module> vspd.debug(filename, port_num, debug_id, debug_options, run_as) File "c:\program files (x86)\microsoft visual studio\2017\community\common7\ide\extensions\microsoft\python\core\Packages\ptvsd\debugger.py", line 37, in debug run(address, filename, *args, **kwargs) File "c:\program files (x86)\microsoft visual studio\2017\community\common7\ide\extensions\microsoft\python\core\Packages\ptvsd\_local.py", line 64, in run_file run(argv, addr, **kwargs) File "c:\program files (x86)\microsoft visual studio\2017\community\common7\ide\extensions\microsoft\python\core\Packages\ptvsd\_local.py", line 125, in _run _pydevd.main() File "c:\program files (x86)\microsoft visual studio\2017\community\common7\ide\extensions\microsoft\python\core\Packages\ptvsd\_vendored\pydevd\pydevd.py", line 1743, in main debugger.connect(host, port) File "c:\program files (x86)\microsoft visual studio\2017\community\common7\ide\extensions\microsoft\python\core\Packages\ptvsd\_vendored\pydevd\pydevd.py", line 1099, in run return self._exec(is_module, entry_point_fn, module_name, file, globals, locals) File "c:\program files (x86)\microsoft visual studio\2017\community\common7\ide\extensions\microsoft\python\core\Packages\ptvsd\_vendored\pydevd\pydevd.py", line 1106, in _exec pydev_imports.execfile(file, globals, locals) # execute the script File "c:\program files (x86)\microsoft visual studio\2017\community\common7\ide\extensions\microsoft\python\core\Packages\ptvsd\_vendored\pydevd\_pydev_imps\_pydev_execfile.py", line 25, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "F:\source\repos\GLN\GLN\GLN\GLN.py", line 99, in <module> model = network_gln() File "F:\source\repos\GLN\GLN\GLN\GLN.py", line 86, in network_gln ln = Conv2D(16, (5,5),strides=1, padding="same", activation="relu")(Add) File "C:\Users\MARUI\AppData\Local\conda\conda\envs\DeepLearning\lib\site-packages\keras\engine\base_layer.py", line 414, in __call__ self.assert_input_compatibility(inputs) File "C:\Users\MARUI\AppData\Local\conda\conda\envs\DeepLearning\lib\site-packages\keras\engine\base_layer.py", line 285, in assert_input_compatibility str(inputs) + '. All inputs to the layer ' ValueError: Layer conv2d_1 was called with an input that isn't a symbolic tensor. Received type: <class 'keras.layers.merge.Concatenate'>. Full input: [<keras.layers.merge.Concatenate object at 0x000002F0AFBF9D30>]. All inputs to the layer should be tensors.
###コード
Python
1import os 2import cv2 3import numpy as np 4from keras.layers import Input, Conv2D, MaxPooling2D, UpSampling2D, Add, BatchNormalization, Activation, Dense, Flatten, Concatenate 5from keras.models import Model 6import keras.optimizers as optimizers 7from tensorflow.python.keras import backend as K 8import matplotlib.pyplot as plt 9 10IMAGE_SIZE = 16 11 12""" 13前略 14""" 15def network_gln(): 16 input = Input(shape=(256,)) 17 input2 = Input(shape=(IMAGE_SIZE,IMAGE_SIZE,1)) 18 19 x1 = Dense(256, activation="relu")(input) 20 x1 = Dense(256, activation="relu")(x1) 21 x1 = Dense(256)(x1) 22 x1 = Dense(16384)(x1) 23 24 25 x2 = UpSampling2D((2,2))(input2) 26 x2 = UpSampling2D((2,2))(x2) 27 x2 = UpSampling2D((2,2))(x2) 28 29 Add = Concatenate([x1,x2]) 30 31 ln = Conv2D(16, (5,5),strides=1, padding="same", activation="relu")(Add) 32 ln = Conv2D(32, (7,7),strides=1, padding="same", activation="relu")(ln) 33 ln = Conv2D(64, (7,7),strides=1, padding="same", activation="relu")(ln) 34 ln = Conv2D(64, (7,7),strides=1, padding="same", activation="relu")(ln) 35 ln = Conv2D(64, (7,7),strides=1, padding="same", activation="relu")(ln) 36 ln = Conv2D(32, (7,7),strides=1, padding="same", activation="relu")(ln) 37 ln = Conv2D(16, (5,5),strides=1, padding="same", activation="relu")(ln) 38 output = Conv2D(1, (5,5),strides=1, padding="same")(ln) 39 40 model = Model(input, output) 41 42 return model 43 44model = network_gln()
試したこと
このエラーが出る前に、Upsamplingしたもの(x2)をDense(16384)層に通して同じ次元に直そうと試みましたが、同じエラーが出ました。
またx1の最後でnp.reshape(128,128)を試しましたがエラーがでて変形できませんでした。
環境
Windows10
Python3.6
Keras 2.2.4
Tensorflow-gpu 1.13.1
opencv 3.4.2