callNN.py 1.01 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#imports
import tensorflow as tf
import numpy as np
import tensorflow.keras.backend as K
# make the network a gobal variable here

#model = tf.python.keras.engine.sequential.Sequential()
    #tf.keras.Model()

def call_network(input):
    inputNP = np.asarray([input])
    model = tf.keras.models.load_model('saved_model/my_model')

    print("input")
    print(inputNP)

    predictions = model.predict(inputNP)

    print("network called")

    print(predictions)
    print(predictions[0])
    print("python out")

    print(predictions[0].shape)
    print(np.zeros(4).shape)

    output = np.zeros(4)
    for i in range(0, 3):
        output[i] = predictions[0, i]

    return output


def initialize_network():
    # Load model
    model = tf.keras.models.load_model('saved_model/my_model')

    # Check its architecture
    model.summary()

    print("network initizalized")
    return 0


def main():
    input = [0,1,2,3]

    initialize_network()
    call_network(input)

    return 0


if __name__ == '__main__':
    main()