def get_cost(aes, l, eye=True):
"""Get the sum of all the reconstruction costs of the AEs.
Input:
aes_in: list. List of all the aes.
l: shared variable or a list of shared variables for the importance
weights.
"""
costs = []
for ae, i in zip(aes, range(len(aes))):
if isinstance(ae, ConvolutionalAutoencoder):
costs.append(l[i] * ae.get_train_cost()[0])
else:
costs.append(l[i] * ae.get_train_cost(face=eye)[0])
cost = None
if costs not in [[], None]:
cost = reduce(lambda x, y: x + y, costs)
return cost
评论列表
文章目录