我有一个txt文件,有8列,我选择1列为我的特征提取,这给我13个特征值,输出数组的形状将是[1x13]。 类似地,我在一个文件夹中有5个txt文件,我想运行一个循环,这样返回的变量将有5x13数据。在
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
在上面的函数中,我可以将[1x13]转换为变量“pool”,我期望变量poolfinal的大小为[5x13],但我得到的却是[1x13]。 如何在垂直方向上连接? 我在循环中犯了什么错误?在
每个循环从sctratch创建pool和poolfinal。这就是为什么在poolfinal中只能看到一个数据。 请尝试以下操作:
相关问题 更多 >
编程相关推荐