как открыть файл .bin с несколькими типами в Python? - PullRequest
0 голосов
/ 13 июля 2020

Я пытался открыть .bin файл с помощью np.fromfile. Однако я не уверен, как правильно загрузить файл. Вот код, который создал этот .bin-файл. Спасибо!

def write_bin(file_path,data_np): #data_np is a float32 array with shape (1, 64, 1)
    file_path   = file_path + '.bin'
    dim_np      = np.array((data_np.shape),dtype=np.int32)  
    dim_num     = np.int32(len(dim_np)) 
    
    output_file = open(file_path, 'wb') 
    output_file.write(dim_num) # write dim_num (np.int32)
    output_file.write(np.array(dim_np)) # write dim_np  (np.int32)
    output_file.write((data_np)) # write array (np.float32)
    output_file.close()
    return
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...