Skip to content
Snippets Groups Projects
Commit 833fdd87 authored by André Anjos's avatar André Anjos :speech_balloon:
Browse files

Add roll/unroll test

parent 8397399d
No related branches found
No related tags found
No related merge requests found
......@@ -21,7 +21,7 @@ include_dirs = [
xbob.core.get_include(),
]
packages = ['bob-io >= 2.0.0a2']
packages = ['bob-io >= 2.0.0a2', 'bob-machine >= 2.0.0a2']
version = '2.0.0a0'
setup(
......
#!/usr/bin/env python
# vim: set fileencoding=utf-8 :
# Laurent El Shafey <Laurent.El-Shafey@idiap.ch>
# Tue Jun 25 20:44:40 CEST 2013
#
# Copyright (C) 2011-2014 Idiap Research Institute, Martigny, Switzerland
"""Tests on the roll/unroll functions
"""
import numpy
from . import Machine, roll, unroll
def test_roll_1(self):
m = Machine((10,3,8,5))
m.randomize()
vec = unroll(m)
m2 = Machine((10,3,8,5))
roll(m2, vec)
assert m == m2
m3 = Machine((10,3,8,5))
vec = unroll(m.weights, m.biases)
roll(m3, vec)
assert m == m3
def test_roll_2(self):
w = [numpy.array([[2,3.]]), numpy.array([[2,3,4.],[5,6,7]])]
b = [numpy.array([5.,]), numpy.array([7,8.])]
vec = numpy.ndarray(11, numpy.float64)
unroll(w, b, vec)
w_ = [numpy.ndarray((1,2), numpy.float64), numpy.ndarray((2,3), numpy.float64)]
b_ = [numpy.ndarray(1, numpy.float64), numpy.ndarray(2, numpy.float64)]
roll(w_, b_, vec)
assert (w_[0] == w[0]).all()
assert (b_[0] == b[0]).all()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment