File size: 4,295 Bytes
9f14ff7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import streamlit as st
import matplotlib.pyplot as plt
import networkx as nx


st.set_page_config(page_title="APRENDIZADO FEDERADO PARA PREVISÃO DE DEMANDA ENERGÉTICA", page_icon=":bar_chart:", layout="wide", initial_sidebar_state="auto")

st.markdown("<h2 style='text-align: center;'>FL com Flower </h2>", unsafe_allow_html=True)
st.sidebar.image("images/logo_inmetro.jpg", width=200)
st.sidebar.title("FL Inmetro")

secao = st.sidebar.radio("Ir para:", ["🏠 Início", "📚 Artigos", "ℹ️ Sobre"])

if secao == "🏠 Início":

    intro, agregamentos, clients_server,FL,sainda, integracao_rpi = st.tabs(['Introducão', 'Métodos de Agregação', 
        'Criando o Cliente e Servidor', 'Modelo', 'Saida', 'Integração com RPI'])

    with intro:

        st.title("Aprendizado Federado")

        col1, col2 = st.columns(2)

        with col1:
            # Introdução

            st.markdown("""

            Este projeto explora o aprendizado federado utilizando o **Flower**.

            Os principais passos incluem:

            - Criar código básico de FL com Flower

            - Configurar clientes e servidor

            - Testar na base CIFAR-10

            """)
            
        with col2:
            # Criando um fluxograma do processo
            st.markdown("""

            1. **Aprender FL com Flower**: Estudo e configuração inicial.

            2. **Criar Clientes e Servidor**: Implementação prática do FL.

            3. **Testar na base CIFAR-10**: Avaliação do modelo treinado.

            4. **Analisar Resultados**: Verificação do desempenho do modelo.

            """)
    with agregamentos:
        col1, col2 = st.columns(2)
        with col1:
            st.subheader(
            """

            Federated Averaging (FedAvg)

            """
            )
            st.image("./images/fedavg.png")
            st.markdown("[McMaham et al. 2023. Communication-Efficient Learning of Deep Networks from Decentralized Data](https://arxiv.org/pdf/1602.05629)")

            st.markdown("""

            - Normalmente, a taxa de convergência do FEDAVG piora com a heterogeneidade do cliente.

            - 

            """)
        with col2:
            st.subheader("FedAdagrad, FedYogi, FedAdam")
            st.image('./images/FedAdaGrad-Yogi-Adam.png')
            st.markdown("[Reddi et al. DAPTIVE FEDERATED OPTIMIZATION](https://arxiv.org/pdf/2003.00295)")

        
        
    with clients_server:
        st.subheader("1. Criar Código de FL com Flower")
        st.code("""

            import flwr as fl

            import tensorflow as tf



            # Definição do modelo e cliente FLwr

            class Client(fl.client.NumPyClient):

                def get_parameters(self, config):

                    return model.get_weights()

                def fit(self, parameters, config):

                    model.set_weights(parameters)

                    model.fit(X_train, y_train, epochs=1)

                    return model.get_weights(), len(X_train), {}



            fl.client.start_numpy_client(server_address="127.0.0.1:8080", client=Client())

            """, language='python')

        st.subheader("2. Criar e Gerenciar Clientes e Servidor")
        st.code("""

            # Servidor FLwr

            import flwr as fl

            fl.server.start_server(config=fl.server.ServerConfig(num_rounds=3))

            """, language='python')

        st.subheader("3. Testar na Base CIFAR-10")
        st.markdown("Carregando e treinando modelo na base CIFAR-10...")

if secao == "ℹ️ Sobre":
    st.markdown(
        """

        Este é um projeto para previsão de demanda de combustível utilizando aprendizado federado.

        Integrantes:

        - João

        - Erick

        - José Wilson

        """
    )
if secao == "📚 Artigos":
    st.markdown(
        """

        ### Referências

        - FedAVG



        [McMaham et al. 2023. Communication-Efficient Learning of Deep Networks from Decentralized Data](https://arxiv.org/pdf/1602.05629)

        

        - ADAGRAD, ADAM, YOGI



        [Reddi et al. DAPTIVE FEDERATED OPTIMIZATION](https://arxiv.org/pdf/2003.00295)

        """
    )