def _setup_vars(self, sparse_input):
'''Setup Theano variables for our network.
Parameters
----------
sparse_input : bool
If True, create an input variable that can hold a sparse matrix.
Defaults to False, which assumes all arrays are dense.
Returns
-------
vars : list of theano variables
A list of the variables that this network requires as inputs.
'''
# x represents our network's input.
self.x = TT.matrix('x')
if sparse_input:
self.x = SS.csr_matrix('x')
# this variable holds the target outputs for input x.
self.targets = TT.matrix('targets')
# the weight array is provided to ensure that different target values
# are taken into account with different weights during optimization.
self.weights = TT.matrix('weights')
if self.weighted:
return [self.x, self.targets, self.weights]
return [self.x, self.targets]
评论列表
文章目录