Example #1
0
 def test_tf(self):
     with self.graph_on_cpu() as g:
         x = tf.constant(_input_tensor())
         y = flatten(x)
         with self.test_session() as sess:
             result = sess.run(y)
     self.assertCorrent(result)
Example #2
0
 def kernel(self, inputs):
     x = inputs[self.KEYS.TENSOR.HITS]
     x = flatten(x)
     m = identity
     models = []
     for i in range(3):
         models += [Dense(self.config(self.KEYS.CONFIG.NB_UNITS)
                          [i], info='dense_{}'.format(i)),
                    ReLU,
                    DropOut()]
     # models.append(DropOut())
     models.append(
         Dense(self.config(self.KEYS.CONFIG.MAX_NB_HITS), info='dense_end'))
     seq = self.graphs.get('seq', Stack(info='stack', models=models))
     return seq(x)
Example #3
0
 def kernel(self, inputs):
     x = inputs[self.KEYS.TENSOR.HITS]
     x = flatten(x)
     m = identity
     models = []
     for i in range(len(self.config(self.KEYS.CONFIG.NB_UNITS))):
         models += [Dense(self.config(self.KEYS.CONFIG.NB_UNITS)
                          [i], info='dense_{}'.format(i)),
                    ReLU,
                    DropOut()]
     models.append(
         Dense(self.config(self.KEYS.CONFIG.MAX_NB_HITS), info='dense_end'))
     if self.graphs.get(self.KEYS.GRAPH.SEQUENTIAL) is None:
         self.graphs[self.KEYS.GRAPH.SEQUENTIAL] = Sequential(
             info='stack', models=models)
     return self.graphs[self.KEYS.GRAPH.SEQUENTIAL](x)
Example #4
0
def test_cntk():
    x = cntk.input([2, 2], np.float32)
    y = flatten(x)
    result = y.eval({x: _input_tensor()})
    _assert_correct(result)
Example #5
0
 def test_np(self):
     x = flatten(_input_tensor())
     self.assertCorrent(x)