Update m1_tf_test.py
This commit is contained in:
1 parent
6432eaafcf
commit
851a2f92b2
1 file changed
+9
-8
+9
-8
@@ -31,13 +31,12 @@ class ComputeSum(Layer):
|
|||||||
n = len(data)
|
n = len(data)
|
||||||
return n
|
return n
|
||||||
|
|
||||||
def ComputeSumModel(input_shape):
|
def ComputeSumModel(input_shape):
|
||||||
inputs = Input(shape = input_shape)
|
inputs = Input(shape = input_shape)
|
||||||
outputs = ComputeSum(input_shape[0])(inputs)
|
outputs = ComputeSum(input_shape[0])(inputs)
|
||||||
|
model = tf.keras.Model(inputs = inputs, outputs = outputs)
|
||||||
|
|
||||||
model = tf.keras.Model(inputs = inputs, outputs = outputs)
|
return model
|
||||||
|
|
||||||
return model
|
|
||||||
|
|
||||||
def xatoi(Str):
|
def xatoi(Str):
|
||||||
|
|
||||||
@@ -71,7 +70,7 @@ def xatoi(Str):
|
|||||||
return base * sign
|
return base * sign
|
||||||
|
|
||||||
inputs = tf.keras.Input(shape=(xatoi(sys.argv[1]),), name="digits")
|
inputs = tf.keras.Input(shape=(xatoi(sys.argv[1]),), name="digits")
|
||||||
model = tf.keras.models.load_model('model')
|
|
||||||
mnist = tf.keras.datasets.mnist
|
mnist = tf.keras.datasets.mnist
|
||||||
(x_train, y_train), (x_test, y_test) = mnist.load_data()
|
(x_train, y_train), (x_test, y_test) = mnist.load_data()
|
||||||
x_train, x_test = x_train / randrange(255+1), x_test / randrange(255+1)
|
x_train, x_test = x_train / randrange(255+1), x_test / randrange(255+1)
|
||||||
@@ -93,8 +92,10 @@ model.compile(optimizer='adam', loss=loss_fn, metrics=['accuracy'])
|
|||||||
these = model.fit(x_train, y_train, epochs=10).history
|
these = model.fit(x_train, y_train, epochs=10).history
|
||||||
that = ComputeSum(len(these))
|
that = ComputeSum(len(these))
|
||||||
those = that(these)
|
those = that(these)
|
||||||
|
print(those)
|
||||||
model = ComputeSumModel((tf.shape(these)[1],))
|
model = ComputeSumModel((tf.shape(these)[1],))
|
||||||
|
print(model(these))
|
||||||
model = tf.keras.Model(inputs=inputs, outputs=outputs)
|
model = tf.keras.Model(inputs=inputs, outputs=outputs)
|
||||||
model.build()
|
model.build()
|
||||||
model.save('model')
|
model.save(these)
|
||||||
model.summary()
|
model.summary()
|
||||||
Reference in new issue
Block a user