<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      tensorflow 批次讀取文件內(nèi)的數(shù)據(jù),并將順序隨機化處理. --[python]

      使用tensorflow批次的讀取預(yù)處理之后的文本數(shù)據(jù),并將其分為一個迭代器批次:

      比如此刻,我有一個處理之后的數(shù)據(jù)包: data.csv  shape =(8,10),其中這個結(jié)構(gòu)中,前五個列為feature , 后五列為label

      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
      1,1,1,1,1,2,2,2,2,2
      3,3,3,3,3,4,4,4,4,4

      現(xiàn)在我需要將其分為4個批次: 也就是每個批次batch的大小為2

      然后我可能需要將其順序打亂,所以這里提供了兩種方式,順序和隨機

      #!/usr/bin/env python
      # -*- coding: utf-8 -*-
      __author__ = 'xijun1'
      import tensorflow as tf
      import numpy as np
      
      # data = np.arange(1, 100 + 1)
      # print ",".join( [str(i) for i in data])
      # data_input = tf.constant(data)
      filename_queue = tf.train.string_input_producer(["data.csv"])
      reader = tf.TextLineReader(skip_header_lines=0)
      key, value = reader.read(filename_queue)
      # decode_csv will convert a Tensor from type string (the text line) in
      # a tuple of tensor columns with the specified defaults, which also
      # sets the data type for each column
      words_size = 5  # 每一行數(shù)據(jù)的長度
      decoded = tf.decode_csv(
          value,
          field_delim=',',
          record_defaults=[[0] for i in range(words_size * 2)])
      
      batch_size = 2 # 每一個批次的大小
      # 隨機
      batch_shuffle = tf.train.shuffle_batch(decoded, batch_size=batch_size,
                                             capacity=batch_size * words_size,
                                             min_after_dequeue=batch_size)
      #順序
      batch_no_shuffle = tf.train.batch(decoded, batch_size=batch_size, capacity=batch_size * words_size,
                                        allow_smaller_final_batch=batch_size)
      shuffle_features = tf.transpose(tf.stack(batch_shuffle[0:words_size]))
      shuffle_label = tf.transpose(tf.stack(batch_shuffle[words_size:]))
      features = tf.transpose(tf.stack(batch_no_shuffle[0:words_size]))
      label = tf.transpose(tf.stack(batch_no_shuffle[words_size:]))
      
      with tf.Session() as sess:
          coord = tf.train.Coordinator()
          threads = tf.train.start_queue_runners(coord=coord)
          for i in range(8/batch_size):
              print (i+10, sess.run([shuffle_features, shuffle_label]))
              print (i, sess.run([features, label]))
          coord.request_stop()
          coord.join(threads)

      當(dāng)我們運行的時候,我們可以得到這個結(jié)果:

      (10, [array([[ 1,  2,  3,  4,  5],
             [31, 32, 33, 34, 35]], dtype=int32), array([[ 6,  7,  8,  9, 10],
             [36, 37, 38, 39, 40]], dtype=int32)])
      (0, [array([[11, 12, 13, 14, 15],
             [21, 22, 23, 24, 25]], dtype=int32), array([[16, 17, 18, 19, 20],
             [26, 27, 28, 29, 30]], dtype=int32)])
      (11, [array([[51, 52, 53, 54, 55],
             [ 3,  3,  3,  3,  3]], dtype=int32), array([[56, 57, 58, 59, 60],
             [ 4,  4,  4,  4,  4]], dtype=int32)])
      (1, [array([[41, 42, 43, 44, 45],
             [ 1,  1,  1,  1,  1]], dtype=int32), array([[46, 47, 48, 49, 50],
             [ 2,  2,  2,  2,  2]], dtype=int32)])
      (12, [array([[ 3,  3,  3,  3,  3],
             [11, 12, 13, 14, 15]], dtype=int32), array([[ 4,  4,  4,  4,  4],
             [16, 17, 18, 19, 20]], dtype=int32)])
      (2, [array([[ 1,  2,  3,  4,  5],
             [21, 22, 23, 24, 25]], dtype=int32), array([[ 6,  7,  8,  9, 10],
             [26, 27, 28, 29, 30]], dtype=int32)])
      (13, [array([[31, 32, 33, 34, 35],
             [ 1,  1,  1,  1,  1]], dtype=int32), array([[36, 37, 38, 39, 40],
             [ 2,  2,  2,  2,  2]], dtype=int32)])
      (3, [array([[41, 42, 43, 44, 45],
             [ 1,  1,  1,  1,  1]], dtype=int32), array([[46, 47, 48, 49, 50],
             [ 2,  2,  2,  2,  2]], dtype=int32)])

       

      posted @ 2018-11-30 18:14  龔細軍  閱讀(3006)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 无码人妻丰满熟妇片毛片| 亚洲男人的天堂久久香蕉| 国产又色又爽又黄的网站免费| 久久婷婷综合色丁香五月| 国产精品七七在线播放| 日本公妇乱偷中文字幕| 天堂av最新版中文在线| 蜜芽久久人人超碰爱香蕉| 四虎影视永久无码精品| 日本高清视频色wwwwww色| 免费无码中文字幕A级毛片| 99久久无码一区人妻a黑 | 人妻久久久一区二区三区| 99精品国产一区二区三区2021| 日本高清久久一区二区三区| 亚洲国产美女精品久久久| 国产精品中文字幕av| 成人aⅴ综合视频国产| 国产AV影片麻豆精品传媒| 日本阿v片在线播放免费| 国产在线午夜不卡精品影院| 亚洲综合区激情国产精品| 精品久久久无码中文字幕| 国产一区二区亚洲一区二区三区| 久久精品噜噜噜成人av| 国产成人精品无码播放| 女人张开腿无遮无挡视频| 精品人妻系列无码人妻漫画| 色综合久久精品亚洲国产| 亚洲一区二区三区播放| 亚洲av天堂天天天堂色| 东方四虎av在线观看| 亚洲欧美日韩在线码| 91精品人妻中文字幕色| 国产色无码专区在线观看| 国产一级特黄性生活大片| 中文字幕日韩有码av| 在线播放亚洲成人av| 亚洲av中文乱码一区二| 丁香花成人电影| 高颜值午夜福利在线观看|