TFRecord作為tensorflow中廣泛使用的數(shù)據(jù)格式,它跨平臺,省空間,效率高。因為 Tensorflow開發(fā)者眾多,統(tǒng)一訓練時數(shù)據(jù)的文件格式是一件很有意義的事情,也有助于降低學習成本和遷移成本。
但是TFRecord數(shù)據(jù)是二進制格式,沒法直接查看。因此,如何能夠方便的查看TFRecord格式和數(shù)據(jù),就顯得尤為重要了。
為什么需要查看TFReocrd數(shù)據(jù)?首先我們先看下常規(guī)的寫入和讀取TFRecord數(shù)據(jù)的關鍵過程。
# 1. 寫入過程 # 一張圖片,我寫入了其內(nèi)容,label,長和寬幾個信息 tf_example = tf.train.Example( features=tf.train.Features(feature={ 'encoded': bytes_feature(encoded_jpg), 'label': int64_feature(label), 'height': int64_feature(height), 'width': int64_feature(width)})) # 2. 讀取過程 # 定義解析的TFRecord數(shù)據(jù)格式 def _parse_image(example_proto): features = {'encoded':tf.FixedLenFeature((),tf.string), 'label': tf.FixedLenFeature((), tf.int64), 'height': tf.FixedLenFeature((), tf.int64), 'width': tf.FixedLenFeature((), tf.int64) } return tf.parse_single_example(example_proto, features) # TFRecord數(shù)據(jù)按照Feature解析出對應的真實數(shù)據(jù) ds = ds.map(lambda x : _parse_image(x), num_parallel_calls=4)
當前名稱:TFRecord文件查看包含的所有Features代碼-創(chuàng)新互聯(lián)
分享地址:http://m.rwnh.cn/article32/ggcsc.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供定制網(wǎng)站、網(wǎng)站導航、虛擬主機、品牌網(wǎng)站設計、軟件開發(fā)、外貿(mào)網(wǎng)站建設
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容