def to_configs(states, verbose=True, **kwargs):
base = panels.shape[1]
dim = states.shape[1] - pad*2
size = dim // base
def build():
states = Input(shape=(dim+2*pad,dim+2*pad))
s = tensor_swirl(states, radius=dim+2*pad * relative_swirl_radius, **unswirl_args)
error = build_errors(s,base,pad,dim,size)
matches = 1 - K.clip(K.sign(error - threshold),0,1)
# a, h, w, panel
matches = K.reshape(matches, [K.shape(states)[0], size * size, -1])
# a, pos, panel
config = matches * K.arange(2,dtype='float')
config = K.sum(config, axis=-1)
# this is 0,1 configs; for compatibility, we need -1 and 1
config = - (config - 0.5)*2
return Model(states, wrap(states, K.round(config)))
return build().predict(states, **kwargs)
评论列表
文章目录