def __init__(self, n_hidden=10, max_iter=10000, tol=1e-5, anneal=True, missing_values=None,
discourage_overlap=True, gaussianize='standard', gpu=False,
verbose=False, seed=None):
self.m = n_hidden # Number of latent factors to learn
self.max_iter = max_iter # Number of iterations to try
self.tol = tol # Threshold for convergence
self.anneal = anneal
self.eps = 0 # If anneal is True, it's adjusted during optimization to avoid local minima
self.missing_values = missing_values
self.discourage_overlap = discourage_overlap # Whether or not to discourage overlapping latent factors
self.gaussianize = gaussianize # Preprocess data: 'standard' scales to zero mean and unit variance
self.gpu = gpu # Enable GPU support for some large matrix multiplications.
if self.gpu:
cm.cublas_init()
self.yscale = 1. # Can be arbitrary, but sets the scale of Y
np.random.seed(seed) # Set seed for deterministic results
self.verbose = verbose
if verbose:
np.set_printoptions(precision=3, suppress=True, linewidth=160)
print(('Linear CorEx with {:d} latent factors'.format(n_hidden)))
# Initialize these when we fit on data
self.n_samples, self.nv = 0, 0 # Number of samples/variables in input data
self.ws = np.zeros((0, 0)) # m by nv array of weights
self.moments = {} # Dictionary of moments
self.theta = None # Parameters for preprocessing each variable
self.history = {} # Keep track of values for each iteration
self.last_update = 0 # Used for momentum methods
评论列表
文章目录