name added as a parameter of Prod

This commit is contained in:
Ricardo 2014-03-05 12:52:56 +00:00
parent 8e22373a00
commit 19c87c9f77
2 changed files with 7 additions and 5 deletions

View file

@ -129,7 +129,7 @@ class Kern(Parameterized):
"""
return self.prod(other, tensor=True)
def prod(self, other, tensor=False):
def prod(self, other, tensor=False, name=None):
"""
Multiply two kernels (either on the same space, or on the tensor
product of the input space).
@ -142,4 +142,4 @@ class Kern(Parameterized):
"""
assert isinstance(other, Kern), "only kernels can be added to kernels..."
from prod import Prod
return Prod(self, other, tensor)
return Prod(self, other, tensor, name)

View file

@ -15,14 +15,16 @@ class Prod(Kern):
:rtype: kernel object
"""
def __init__(self, k1, k2, tensor=False):
def __init__(self, k1, k2, tensor=False,name=None):
if tensor:
super(Prod, self).__init__(k1.input_dim + k2.input_dim, k1.name + '_xx_' + k2.name)
name = k1.name + '_xx_' + k2.name if name is None else name
super(Prod, self).__init__(k1.input_dim + k2.input_dim, name)
self.slice1 = slice(0,k1.input_dim)
self.slice2 = slice(k1.input_dim,k1.input_dim+k2.input_dim)
else:
assert k1.input_dim == k2.input_dim, "Error: The input spaces of the kernels to multiply don't have the same dimension."
super(Prod, self).__init__(k1.input_dim, k1.name + '_x_' + k2.name)
name = k1.name + '_x_' + k2.name if name is None else name
super(Prod, self).__init__(k1.input_dim, name)
self.slice1 = slice(0, self.input_dim)
self.slice2 = slice(0, self.input_dim)
self.k1 = k1