๐Ÿ‘‰Trouble viewing the content, videos, equations or code of this email? View it in your browser.
ANNs: Non-Linear Regressor: Implementation in a Microcontroller - 26a

sensor and ANN connection scheme

ย 

Dear Students Student,๐Ÿ“š๐Ÿ“โœจ

To ensure a smooth process of submitting your assignment and guaranteeing that your hard work gets the recognition it deserves, I have prepared a brief guide to help you navigate the submission process for this particular assignment: Non-linear regressor in a microcontroller. Follow these steps to avoid last-minute hassles and ensure your assignment reaches the intended recipients without any glitches.

Note: Please consider that this session must be presented running on the microcontroller (Arduino-uno, MSP430, or other)

1. Main goal ๐Ÿ“–โœ๏ธ:

2. Nonlinear Relationship ๐Ÿงฎ๐Ÿ“‰:

ย 

Data for creating insstancess

ย 

The next point must be covered to present your model successfully:

ย 

3. Create the model using TensorFlow ๐Ÿ:


    import tensorflow as tf
    from tensorflow.keras.models import Sequential
    from tensorflow.keras.layers import Dense, Input
ย 
l0 = Input(shape=(1,), name='l0')
l1 = Dense(units=20, activation='linear', name='l1') l2 = Dense(units=1, activation='linear', name='l2') model = Sequential([l0, l1, l2])

4. Prepared input data :

Scaler equation


    from sklearn.preprocessing import StandardScaler
    scaler = StandardScaler().fit(input)
    inpScaler = scaler.transform(input) # data ready for ANN
  

5. Train the model ๐Ÿ“ˆ๐Ÿ”:

 ย  ย  from tensorflow.keras.optimizers import Adam
modelo.compile(optimizer=Adam(0.1), loss='mean_squared_error')
historial = modelo.fit(celsius, fahrenheit, epochs=100, verbose=False)
plt.xlabel("# Epochs")
plt.ylabel("MSE")
plt.plot(historial.history["loss"], '.k')
plt.show()

6. Activation functions ๐Ÿ“‹๐Ÿ”:

7. Plot and compare ๐Ÿ“‰๐Ÿ”:

8. ANN implementation ๐Ÿ’ป0๏ธโƒฃ1๏ธโƒฃ:

ย 

    double relu(double x)
    {
    if(x>=0)
    return x;
    else if(x<0)
    return 0;
    }
  

ย 

ย 

Warm regards,

Gerardo Marx

Lecturer