### Inference in Code: an example The task is to find out in a coffee roasting scenario, given *enough time* and *temperature* whether it result to a good coffee (properly roasted) or a bad coffee (overcooked or undercooked. ![[Pasted image 20250606224146.png]] Now in order to implement it in TensorFlow, we could suppose that `x` is an array of two numbers (enough time and temperature): ```python x = np.array([[200, 17]]) layer_1 = Dense(units=3, activation="sigmoid") a1 = layer_1(x) ``` Here we calculated the output of the first layer `a1` by the `Dense` function which is a *kind* of neural network function in TensorFlow. ```python layer_2 = Dense(units=1, activation="sigmoid") a2 = layer_2(a1) ``` Now `a2` is the answer of our algorithm. If we want to get the result, we have to check if it's more than 0.5 or not. > [!tip] > You can define a `model` in TensorFlow and chain out each layer by `Sequential` function: > ```python > model = Sequential([ > Dense(units=3, activation="sigmoid"), > Dense(units=1, activation="sigmoid") > ]) > # model.fit(x, y) > # model.compile() > # model.predict(x_new) > ```