Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Build 如何设置子类模型的输入形状?_Build_Keras_Subclass - Fatal编程技术网

Build 如何设置子类模型的输入形状?

Build 如何设置子类模型的输入形状?,build,keras,subclass,Build,Keras,Subclass,def呼叫(自我,x): 当我第一次调用我的模式(子类)时,我不能检查批处理大小(无) 如果我想连接多个层,模型将检查输入形状 但它不能 如何设置子类模型的输入形状 模型。构建(输入_形状),但无效 def调用(self,x): “转发” #[x,y]=Lambda(Lambda x:[x[0],x[1]],输出形状=[-1,self.opt.ncond,self.opt.nc,self.opt.height,self.opt.width])(x) 输入=重塑((self.opt.ncond*s

def呼叫(自我,x):

当我第一次调用我的模式(子类)时,我不能检查批处理大小(无)

如果我想连接多个层,模型将检查输入形状

但它不能

如何设置子类模型的输入形状

模型。构建(输入_形状),但无效

def调用(self,x):
“转发”
#[x,y]=Lambda(Lambda x:[x[0],x[1]],输出形状=[-1,self.opt.ncond,self.opt.nc,self.opt.height,self.opt.width])(x)
输入=重塑((self.opt.ncond*self.opt.nc,self.opt.height,self.opt.width))(x)#批量大小,形状
目标=重塑((self.opt.npred*self.opt.nc,self.opt.height,self.opt.width))(self.y)
g_pred_v=K.变量(自确定性(输入),name=“g_pred_v”)
r=K.abs(g_pred_v-target)#剩余
z=自功率因数网络转换(r)
s=自确定的获取层()[0](输入)
h=连接([s,z],轴=1)#连接
#形状=K.int_形状
#h=重塑(形状[1]*2,形状[2],形状[3])(h)
pred_f=self.f_网络解码器(h)
返回预定
def get_目标(自我,y):
#输入层
self.y=y

当我第一次尝试“批量训练”时,在向前传球中,输入的形状是清晰的,而不是[无、通道、高度、宽度]

我只能通过调用模型一次来解决这个问题(比如说假数据)。还没有找到其他解决方法。