예제 #1
0
	def geterr(self, err):
		for nc, ne in zip(self.nodes, err.nodes):
			if nc is not None:
				nc.geterr(ne)
		for pc, pe in zip(self.paths, err.paths):
			if pe is not None:
				array.copy(pe, pc)
예제 #2
0
	def _transmit(self, ctx):
		if ctx.trace is not None:
			array.softmax(ctx.trace.odata, ctx.src)
			if ctx.dst is not None:
				array.copy(ctx.dst, ctx.trace.odata)
		else:
			Softmax._transmit(self, ctx)
예제 #3
0
	def setmem(self, mem):
		for nc, nm in zip(self.nodes, mem.nodes):
			if nc is not None:
				nc.setmem(nm)
		for pc, pm in zip(self.paths, mem.paths):
			if pm is not None:
				array.copy(pc, pm)
예제 #4
0
	def _transmit(self, ctx):
		array.copy(ctx.accum, ctx.src[0])
		for i in range(1, self.inum):
			array.radd(ctx.accum, ctx.srcs[i])

		for i in range(self.onum):
			array.copy(ctx.dsts[i], ctx.accum)
예제 #5
0
	def _backprop(self, ctx):
		array.copy(ctx.accum, ctx.dst[0])
		for i in range(1, self.onum):
			array.radd(ctx.accum, ctx.dsts[i])

		for i in range(self.inum):
			array.copy(ctx.srcs[i], ctx.accum)
예제 #6
0
		def set(self, src):
			array.copy(self.odata, src.odata)
예제 #7
0
파일: array.py 프로젝트: nthend/pynnss-test
	factory = array.newFactory(dtype=np.int32)

with Case('_FactoryCPU.empty'):
	a = factory.empty((4, 5))
	assert(a.np.shape == (4, 5))

with Case('_FactoryCPU.zeros'):
	a = factory.zeros((4, 5))
	assert(np.sum(a.get()**2) == 0)

with Case('_FactoryCPU.copynp'):
	npa = np.array([1, 2, 3, 4])
	a = factory.copynp(npa)
	assert(a.np[0] == 1 and a.np[3] == 4)
	assert(a.np is not npa)

with Case('_FactoryCPU.copy'):
	a = factory.copynp(np.array([1, 2, 3]))
	b = factory.copy(a)
	assert(np.all(b.np == a.np))
	assert(a.np is not b.np)

with Case('copy'):
	a, b = factory.empty(4), factory.empty(4)
	a.np[0] = 1
	array.copy(b, a)
	a.np[0] = 2
	assert(b.np[0] == 1)

# to be continued ...
예제 #8
0
	def _transmit(self, ctx):
		if ctx.trace is not None:
			array.copy(ctx.trace.idata, ctx.src)
		array.dot(ctx.dst, ctx.src, ctx.state.data)
예제 #9
0
	def _backprop(self, ctx):
		array.copy(ctx.srcs[0], ctx.dst)
		array.copy(ctx.srcs[1], ctx.dst)
예제 #10
0
	def _transmit(self, ctx):
		array.copy(ctx.dsts[0], ctx.src)
		array.copy(ctx.dsts[1], ctx.src)
예제 #11
0
	def _transmit(self, ctx):
		array.tanh(ctx.dst, ctx.src)
		if ctx.trace is not None:
			array.copy(ctx.trace.odata, ctx.dst)
예제 #12
0
	def _backprop(self, ctx):
		array.copy(ctx.src, ctx.dst)
예제 #13
0
	def _transmit(self, ctx):
		array.copy(ctx.dst, ctx.src)
예제 #14
0
	def _backprop(self, ctx):
		if ctx.grad is not None:
			array.radd(ctx.grad.data, ctx.dst)
		array.copy(ctx.src, ctx.dst)
예제 #15
0
    factory = array.newFactory(dtype=np.int32)

with Case('_FactoryCPU.empty'):
    a = factory.empty((4, 5))
    assert (a.np.shape == (4, 5))

with Case('_FactoryCPU.zeros'):
    a = factory.zeros((4, 5))
    assert (np.sum(a.get()**2) == 0)

with Case('_FactoryCPU.copynp'):
    npa = np.array([1, 2, 3, 4])
    a = factory.copynp(npa)
    assert (a.np[0] == 1 and a.np[3] == 4)
    assert (a.np is not npa)

with Case('_FactoryCPU.copy'):
    a = factory.copynp(np.array([1, 2, 3]))
    b = factory.copy(a)
    assert (np.all(b.np == a.np))
    assert (a.np is not b.np)

with Case('copy'):
    a, b = factory.empty(4), factory.empty(4)
    a.np[0] = 1
    array.copy(b, a)
    a.np[0] = 2
    assert (b.np[0] == 1)

# to be continued ...