2017-01-23 14 views
0

私は8個の列を持つtxtファイルを持っています。私は13個の特徴値を与える私の特徴抽出のために1列を選択します。出力配列の形状は[1x13]になります。 同様に、返される変数に5x13のデータがあるように、ループを実行するフォルダに5つのtxtファイルがあります。私は[1x13]変数への「プール」を取得することができています上記の関数でテンソルフローで配列の多次元を増やす方法は?

def loadinfofromfile(directory,sd,channel): 
    # subdir selection and read file names in it for particular crack type. 
    subdir, filenames = loadfilenamesindirectory(directory,sd) 
    for i in range(5): 
     # join the directory sub directory and the filename 
     loadfile = os.path.join(directory,subdir,filenames[i]) 
     # load the values of that paticular file into tensor 
     fileinfo = tf.constant(np.loadtxt(loadfile),tf.float32) 
     # select the particular column data (choosen from crack type, channel no) 
     fileinfo_trans = tf.transpose(fileinfo) 
     fileinfo_back = tf.gather(fileinfo_trans,channel) 
     # extracting features from selected column data gives [1x13] 
     pool = features.pooldata(fileinfo_back) 
     poolfinal = tf.concat_v2([tf.expand_dims(pool,0)],axis=0) 
    return poolfinal 

と私は[5x13]として変数poolfinalの大きさを期待していたが[1x13]として私はそれを取得します。 垂直方向に連結する方法は? 私はループで間違いましたか?

答えて

0

各ループはsctratchからプールとpoolfinalを作成します。そのため、プールフィギュアでは1つのデータしか表示されません。 ではなく、次の手順を試してください。

pools = [] 
for ...: 
    pools.append(...) 
poolfinal = tf.concat_v2(pools, axis=0) 
+0

私はpoolfinalにして、私は関数concat_v2をtensorflow使用してそれを実行することを再びコピーする必要はありませんpool.appendを使用していたときに – Raady