def make_placeholder(input_size, sequence_length, batch_size, extra_axes=0):

    input_axis = ng.make_axis(name='features')
    recurrent_axis = ng.make_axis(name='REC_REP')
    batch_axis = ng.make_axis(name='N')

    input_axes = ng.make_axes([input_axis, recurrent_axis, batch_axis])
    input_axes.set_shape((input_size, sequence_length, batch_size))
    input_axes = ng.make_axes([ng.make_axis(length=1, name='features_' + str(i))
                               for i in range(extra_axes)]) + input_axes

    input_placeholder = ng.placeholder(input_axes)
    rng = RandomTensorGenerator()
    input_value = rng.uniform(-0.01, 0.01, input_axes)

    return input_placeholder, input_value
Exemple #2
0
def make_placeholder(input_size, sequence_length, batch_size, extra_axes=0):

    input_axis = ng.make_axis(name='features')
    recurrent_axis = ng.make_axis(name='REC_REP')
    batch_axis = ng.make_axis(name='N')

    input_axes = ng.make_axes([input_axis, recurrent_axis, batch_axis])
    input_axes.set_shape((input_size, sequence_length, batch_size))
    input_axes = ng.make_axes([
        ng.make_axis(length=1, name='features_' + str(i))
        for i in range(extra_axes)
    ]) + input_axes

    input_placeholder = ng.placeholder(input_axes)
    rng = RandomTensorGenerator()
    input_value = rng.uniform(-0.01, 0.01, input_axes)

    return input_placeholder, input_value
# See the License for the specific language governing permissions and
# limitations under the License.
# ----------------------------------------------------------------------------
'''
Test of the batchnorm layer
'''
import pytest
import numpy as np
import ngraph as ng
from ngraph.frontends.neon import BatchNorm, Recurrent, LSTM, Tanh
from ngraph.testing.random import RandomTensorGenerator
from ngraph.testing.execution import ExecutorFactory

pytestmark = pytest.mark.transformer_dependent

rng = RandomTensorGenerator()
rtol = 0
atol = 1e-6
recurrent_atol = 1e-5


class BatchNormReference(object):
    def __init__(self,
                 x,
                 init_gamma=1.0,
                 init_beta=0.0,
                 gmean=0.0,
                 gvar=1.0,
                 rho=0.9,
                 eps=1e-3,
                 axis=(1, )):