Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as Python by iuper2 ( 7 years ago )
def matrizes(output_file):

    n_linhas = obter_n_linhas(output_file[1:]) - 1

    with open(output_file[1:]) as f:
        data = json.load(f)

    # Percorrendo os objetos dentro do arquivo json

    resultado = []  # inicializando um vetor vazio para receber os valores extraidos do data

    for d in data:
        vetores = []
        for f in data[d]['features']:
            for l in f['layers']:
                vetores.append(l['values'])

        a = np.median(vetores,
                      axis=0)  # Função que retorna um valor único como a média de todos os valores do vetor [0,..,768]
        resultado.append(a)
    x = np.array(resultado)  # x é a matriz que tá gerando randomicamente
    matrix_list = []
    for i in range(0, x.shape[0] - 9):
        n_matrix = x[i:i + 10, 0:]
        matrix_list.append(n_matrix)

    matrizes = np.asarray(matrix_list)
    lista = []
    for i in range(0,matrizes.shape[0]):
        matriz = matrizes[i]
        matriz = cv2.resize(matriz,(28,28))
        lista.append((matriz))
        
    lista = np.asarray(lista)
    lista = lista.reshape(lista.shape[0],784)
    lista = pd.DataFrame(lista)
    lista.to_csv('matriz' + output_file[20:len(output_file) - 5] + '.csv',index=False, header = None)

 

Revise this Paste

Your Name: Code Language: