def test_UpSampling3D(self): inshp = (4, 5, 10, 3) a = keras.layers.Input(inshp) b = keras.layers.UpSampling3D((3, 4, 2))(a) model = keras.models.Model(a, b) name = 'test___UpSampling3D' + str(int(time.time())) keras2c_main.k2c(model, name) rcode = build_and_run(name) self.assertEqual(rcode, 0)
def test_GlobalAveragePooling1D(self): inshp = (16, 11) a = keras.layers.Input(inshp) b = keras.layers.GlobalAveragePooling1D()(a) model = keras.models.Model(inputs=a, outputs=b) name = 'test___GlobalAveragePooling1D' + str(int(time.time())) keras2c_main.k2c(model, name) rcode = build_and_run(name) self.assertEqual(rcode, 0)
def test_PReLU(self): inshp = (3, 6, 9, 3) a = keras.layers.Input(inshp) b = keras.layers.PReLU(alpha_initializer='glorot_uniform')(a) model = keras.models.Model(inputs=a, outputs=b) name = 'test___PReLU' + str(int(time.time())) keras2c_main.k2c(model, name) rcode = build_and_run(name) self.assertEqual(rcode, 0)
def test_Malloc1(self): inshp = (21, 4, 9) units = 45 a = keras.layers.Input(inshp) b = keras.layers.Dense(units, activation='relu')(a) model = keras.models.Model(inputs=a, outputs=b) name = 'test___Malloc1' + str(int(time.time())) keras2c_main.k2c(model, name, malloc=True) rcode = build_and_run(name) self.assertEqual(rcode, 0)
def test_TimeDistributed3(self): model = keras.models.Sequential() model.add(keras.layers.Dense(10, input_shape=(8, 5))) model.add(keras.layers.TimeDistributed( keras.layers.Dense(7, use_bias=True))) model.build() name = 'test___TimeDistributed3' + str(int(time.time())) keras2c_main.k2c(model, name) rcode = build_and_run(name) self.assertEqual(rcode, 0)
def test_ELU(self): inshp = (13, 6, 9, 13) alpha = 1.3 a = keras.layers.Input(inshp) b = keras.layers.ELU(alpha=alpha)(a) model = keras.models.Model(inputs=a, outputs=b) name = 'test___ELU' + str(int(time.time())) keras2c_main.k2c(model, name) rcode = build_and_run(name) self.assertEqual(rcode, 0)
def test_ThresholdedReLU(self): inshp = (3, 6, 19, 11) theta = 0.3 a = keras.layers.Input(inshp) b = keras.layers.ThresholdedReLU(theta=theta)(a) model = keras.models.Model(inputs=a, outputs=b) name = 'test___ThresholdedReLU' + str(int(time.time())) keras2c_main.k2c(model, name) rcode = build_and_run(name) self.assertEqual(rcode, 0)
def test_Cropping1D(self): inshp = (10, 12) crop_top = 3 crop_bottom = 1 a = keras.layers.Input(inshp) b = keras.layers.Cropping1D(cropping=(crop_top, crop_bottom))(a) model = keras.models.Model(inputs=a, outputs=b) name = 'test___Cropping1D' + str(int(time.time())) keras2c_main.k2c(model, name) rcode = build_and_run(name) self.assertEqual(rcode, 0)
def test_TimeDistributed1(self): inputs = keras.layers.Input(shape=(8, 5)) outputs = keras.layers.TimeDistributed( keras.layers.Dense(7, use_bias=True,))(inputs) model = keras.models.Model(inputs, outputs) model.build((None, 8, 5)) name = 'test___TimeDistributed1' + str(int(time.time())) keras2c_main.k2c(model, name) rcode = build_and_run(name) self.assertEqual(rcode, 0)
def test_TimeDistributed6(self): model = keras.models.Sequential() model.add(keras.layers.Dense(10, input_shape=(4, 7, 8, 5))) model.add(keras.layers.TimeDistributed( keras.layers.Conv2D(7, kernel_size=2))) model.add(keras.layers.Dense(10)) model.build() name = 'test___TimeDistributed6' + str(int(time.time())) keras2c_main.k2c(model, name) rcode = build_and_run(name) self.assertEqual(rcode, 0)
def test_ZeroPad1D(self): inshp = (10, 12) pad_top = 3 pad_bottom = 1 a = keras.layers.Input(inshp) b = keras.layers.ZeroPadding1D(padding=(pad_top, pad_bottom))(a) model = keras.models.Model(inputs=a, outputs=b) name = 'test___ZeroPad1D' + str(int(time.time())) keras2c_main.k2c(model, name) rcode = build_and_run(name) self.assertEqual(rcode, 0)
def test_Subtract1(self): inshp1 = (10, 8, 2, 3) inshp2 = (10, 8, 2, 3) a = keras.layers.Input(inshp1) b = keras.layers.Input(inshp2) c = keras.layers.Subtract()([a, b]) model = keras.models.Model(inputs=[a, b], outputs=c) name = 'test___Subtract1' + str(int(time.time())) keras2c_main.k2c(model, name) rcode = build_and_run(name) self.assertEqual(rcode, 0)
def test_Bidirectional1(self): model = keras.models.Sequential() model.add(keras.layers.Bidirectional(keras.layers.LSTM(10, return_sequences=True), input_shape=(5, 10), merge_mode='concat')) model.add(keras.layers.Bidirectional(keras.layers.LSTM(10, return_sequences=True), merge_mode='mul')) model.add(keras.layers.Dense(5)) model.build() name = 'test___Bidirectional1' + str(int(time.time())) keras2c_main.k2c(model, name) rcode = build_and_run(name) self.assertEqual(rcode, 0)
def test_ProfilePredictor(self): inshp = (8, 32) inp = keras.layers.Input(inshp) a = keras.layers.Dense(20, activation='relu')(inp) a = keras.layers.Dense(20, activation='relu')(a) a = keras.layers.LSTM(20, activation='relu')(a) outp = keras.layers.Dense(30)(a) model = keras.models.Model(inp, outp) name = 'test___ProfilePredictor' + str(int(time.time())) keras2c_main.k2c(model, name) rcode = build_and_run(name) self.assertEqual(rcode, 0)
def test_Dot2(self): dotaxes = (2, 2) inshape1 = (5, 9) inshape2 = (9, 9) i1 = keras.layers.Input(inshape1) i2 = keras.layers.Input(inshape2) d = keras.layers.Dot(axes=dotaxes, normalize=True)([i1, i2]) model = keras.models.Model(inputs=[i1, i2], outputs=d) name = 'test___Dot2' + str(int(time.time())) keras2c_main.k2c(model, name) rcode = build_and_run(name) self.assertEqual(rcode, 0)
def test_SimpleRNN2(self): inshp = (34, 17) units = 40 a = keras.layers.Input(inshp) b = keras.layers.SimpleRNN(units, go_backwards=True, return_sequences=True, activation='tanh')(a) model = keras.models.Model(inputs=a, outputs=b) name = 'test___SimpleRNN2' + str(int(time.time())) keras2c_main.k2c(model, name) rcode = build_and_run(name) self.assertEqual(rcode, 0)
def test_SimpleRNN1(self): inshp = (4, 4, 46) units = 17 a = keras.layers.Input(batch_shape=inshp) b = keras.layers.SimpleRNN(units, activation='relu', return_sequences=False, stateful=True)(a) model = keras.models.Model(inputs=a, outputs=b) name = 'test___SimpleRNN1' + str(int(time.time())) keras2c_main.k2c(model, name) rcode = build_and_run(name) self.assertEqual(rcode, 0)
def test_GRU1(self): inshp = (12, 46) units = 17 a = keras.layers.Input(inshp) b = keras.layers.GRU(units, activation='softmax', recurrent_activation='softsign', return_sequences=False)(a) model = keras.models.Model(inputs=a, outputs=b) name = 'test___GRU1' + str(int(time.time())) keras2c_main.k2c(model, name) rcode = build_and_run(name) self.assertEqual(rcode, 0)
def test_LSTM1(self): inshp = (23, 32) units = 19 a = keras.layers.Input(inshp) b = keras.layers.LSTM(units, activation='relu', return_sequences=False, recurrent_activation='hard_sigmoid')(a) model = keras.models.Model(inputs=a, outputs=b) name = 'test___LSTM1' + str(int(time.time())) keras2c_main.k2c(model, name) rcode = build_and_run(name) self.assertEqual(rcode, 0)
def test_Add1(self): inshp1 = (10, 8, 12) inshp2 = (10, 8, 12) inshp3 = (10, 8, 12) a = keras.layers.Input(inshp1) b = keras.layers.Input(inshp2) c = keras.layers.Input(inshp3) d = keras.layers.Add()([a, b, c]) model = keras.models.Model(inputs=[a, b, c], outputs=d) name = 'test___Add1' + str(int(time.time())) keras2c_main.k2c(model, name) rcode = build_and_run(name) self.assertEqual(rcode, 0)
def test_AveragePooling1D1(self): inshp = (23, 29) pool_size = 2 strides = 3 padding = 'valid' a = keras.layers.Input(inshp) b = keras.layers.AveragePooling1D(pool_size=pool_size, strides=strides, padding=padding)(a) model = keras.models.Model(inputs=a, outputs=b) name = 'test___AveragePooling1D1' + str(int(time.time())) keras2c_main.k2c(model, name) rcode = build_and_run(name) self.assertEqual(rcode, 0)
def test_MaxPooling2D2(self): inshp = (13, 19, 4) pool_size = (2, 4) strides = (2, 3) padding = 'same' a = keras.layers.Input(inshp) b = keras.layers.MaxPooling2D(pool_size=pool_size, strides=strides, padding=padding)(a) model = keras.models.Model(inputs=a, outputs=b) name = 'test___MaxPooling2D2' + str(int(time.time())) keras2c_main.k2c(model, name) rcode = build_and_run(name) self.assertEqual(rcode, 0)
def test_ReLU(self): inshp = (12, 7, 9, 21) max_value = 1.0 negative_slope = 1.0 threshold = 0.3 a = keras.layers.Input(inshp) b = keras.layers.ReLU(max_value=max_value, negative_slope=negative_slope, threshold=threshold)(a) model = keras.models.Model(inputs=a, outputs=b) name = 'test___ReLU' + str(int(time.time())) keras2c_main.k2c(model, name) rcode = build_and_run(name) self.assertEqual(rcode, 0)
def test_Concatenate3(self): inshp1 = (2, 3, 6, 3) inshp2 = (3, 3, 6, 3) inshp3 = (1, 3, 6, 3) axis = 1 a = keras.layers.Input(inshp1) b = keras.layers.Input(inshp2) c = keras.layers.Input(inshp3) d = keras.layers.Concatenate(axis=axis)([a, b, c]) model = keras.models.Model([a, b, c], d) name = 'test___Concatenate3' + str(int(time.time())) keras2c_main.k2c(model, name) rcode = build_and_run(name) self.assertEqual(rcode, 0)
def test_LSTM2(self): inshp = (4, 80) units = 23 a = keras.layers.Input(inshp) b = keras.layers.LSTM(units, go_backwards=True, return_sequences=True, activation='sigmoid', recurrent_activation='tanh')(a) model = keras.models.Model(inputs=a, outputs=b) name = 'test___LSTM2' + str(int(time.time())) keras2c_main.k2c(model, name) rcode = build_and_run(name) self.assertEqual(rcode, 0)
def test_Maximum1(self): inshp1 = (9, 14) inshp2 = (9, 14) inshp3 = (9, 14) inshp4 = (9, 14) a = keras.layers.Input(inshp1) b = keras.layers.Input(inshp2) c = keras.layers.Input(inshp3) d = keras.layers.Input(inshp4) e = keras.layers.Maximum()([a, b, c, d]) model = keras.models.Model(inputs=[a, b, c, d], outputs=e) name = 'test___Maximum1' + str(int(time.time())) keras2c_main.k2c(model, name) rcode = build_and_run(name) self.assertEqual(rcode, 0)
def test_GRU3(self): inshp = (12, 46) units = 17 a = keras.layers.Input(inshp) b = keras.layers.GRU(units, activation='softplus', recurrent_activation='sigmoid', return_sequences=True, go_backwards=False, reset_after=True, use_bias=False)(a) model = keras.models.Model(inputs=a, outputs=b) name = 'test___GRU3' + str(int(time.time())) keras2c_main.k2c(model, name) rcode = build_and_run(name) self.assertEqual(rcode, 0)
def test_Cropping3D(self): inshp = (10, 12, 5, 4) crop_top = 3 crop_bottom = 1 crop_left = 4 crop_right = 3 crop_front = 2 crop_back = 0 a = keras.layers.Input(inshp) b = keras.layers.Cropping3D( cropping=((crop_top, crop_bottom), (crop_left, crop_right), (crop_front, crop_back)))(a) model = keras.models.Model(inputs=a, outputs=b) name = 'test___Cropping3D' + str(int(time.time())) keras2c_main.k2c(model, name) rcode = build_and_run(name) self.assertEqual(rcode, 0)
def test_ZeroPad3D(self): inshp = (10, 12, 5, 4) pad_top = 3 pad_bottom = 1 pad_left = 4 pad_right = 3 pad_front = 2 pad_back = 4 a = keras.layers.Input(inshp) b = keras.layers.ZeroPadding3D( padding=((pad_top, pad_bottom), (pad_left, pad_right), (pad_front, pad_back)))(a) model = keras.models.Model(inputs=a, outputs=b) name = 'test___ZeroPad3D' + str(int(time.time())) keras2c_main.k2c(model, name) rcode = build_and_run(name) self.assertEqual(rcode, 0)
def test_Conv2D1(self): inshp = (25, 32, 3) filters = 13 kernel_size = (3, 4) strides = (2, 3) padding = 'valid' dilation_rate = 1 activation = 'relu' a = keras.layers.Input(inshp) b = keras.layers.Conv2D(filters=filters, kernel_size=kernel_size, strides=strides, padding=padding, dilation_rate=dilation_rate, activation=activation, use_bias=False)(a) model = keras.models.Model(inputs=a, outputs=b) name = 'test___Conv2D1' + str(int(time.time())) keras2c_main.k2c(model, name) rcode = build_and_run(name) self.assertEqual(rcode, 0)