def load_weights(params, path, num_conv):
print 'Loading gan weights from ' + path
with h5py.File(path, 'r') as hdf5:
params['skipthought2image'] = theano.shared(np.copy(hdf5['skipthought2image']))
params['skipthought2image-bias'] = theano.shared(np.copy(hdf5['skipthought2image-bias']))
for i in xrange(num_conv):
params['W_conv{}'.format(i)] = theano.shared(np.copy(hdf5['W_conv{}'.format(i)]))
params['b_conv{}'.format(i)] = theano.shared(np.copy(hdf5['b_conv{}'.format(i)]))
# Flip w,h axes
params['W_conv{}'.format(i)] = params['W_conv{}'.format(i)][:,:,::-1,::-1]
w = np.abs(np.copy(hdf5['W_conv{}'.format(i)]))
print 'W_conv{}'.format(i), np.min(w), np.mean(w), np.max(w)
b = np.abs(np.copy(hdf5['b_conv{}'.format(i)]))
print 'b_conv{}'.format(i), np.min(b), np.mean(b), np.max(b)
return params
评论列表
文章目录