Python 2.7 Linux终端输出导出错误

Python 2.7 Linux终端输出导出错误,python-2.7,command-line,anaconda,keras,oh-my-zsh,Python 2.7,Command Line,Anaconda,Keras,Oh My Zsh,我正在运行一个python程序,它使用VGG16神经网络,通过keras包,从Kaggle数据库中对猫和狗的图像进行分类。为此,我使用标准的终端命令:python program.py>output.txt。我还试用了其他变体,python program.py&>output.txt,或者tee命令,python program.py |&tee output.txt,但它似乎不起作用。对于第一个命令,我的文本文件仅包含: 使用TensorFlow后端。 2017-05-31 13:39:34

我正在运行一个python程序,它使用
VGG16
神经网络,通过
keras
包,从Kaggle数据库中对猫和狗的图像进行分类。为此,我使用标准的终端命令:
python program.py>output.txt
。我还试用了其他变体,
python program.py&>output.txt
,或者
tee
命令,
python program.py |&tee output.txt
,但它似乎不起作用。对于第一个命令,我的文本文件仅包含:

使用TensorFlow后端。
2017-05-31 13:39:34.218034:W tensorflow/core/platform/cpu\u feature\u guard.cc:45]
TensorFlow库的编译不是为了使用SSE4.1指令,但它们是
在您的机器上可用,可以加快CPU计算速度。
2017-05-31 13:39:34.226941:W tensorflow/core/platform/cpu\u feature\u guard.cc:45]
TensorFlow库的编译不是为了使用SSE4.2指令,但它们是
在您的机器上可用,可以加快CPU计算速度。
但是代码中有很多
打印
语句!
output.txt
文件的预期内容为(仅显示终端输出的前4-5行):

使用TensorFlow后端。
定义所有路径!
所有路径都已定义!
获取平均RGB并创建标签!
当我只需键入
python program.py
时,就会显示它。该部分:

2017-05-3113:39:34.218034:W tensorflow/core/platform/cpu\u feature\u guard.cc:45]
TensorFlow库的编译不是为了使用SSE4.1指令,但它们是
在您的机器上可用,可以加快CPU计算速度。
2017-05-31 13:39:34.226941:W tensorflow/core/platform/cpu\u feature\u guard.cc:45]
TensorFlow库的编译不是为了使用SSE4.2指令,但它们是
在您的机器上可用,可以加快CPU计算速度。
该部分在终端输出中出现的时间要晚得多。我将我的代码放在这里作为参考,但它有204行长:

导入keras
从keras.models导入顺序、模型
从keras.layers导入平坦、密集、退出、输入、激活
从keras.layers.Conv2D、MaxPoolig2D、ZeroPadding2D卷积导入
从keras.layers.merge导入添加
从keras.optimizers进口新加坡元,Adam
将cv2、numpy作为np导入
导入glob
导入csv
####################
##VGG16函数##
####################
def VGG_16(权重路径=无,类别=2):
######################################
##输入:3x224x24大小的RGB输入##
######################################
输入=输入(形状=(3224224))
层=0
#############
##第一区##
#############
x=Conv2D(64,(3,3),数据格式为通道优先,激活为relu,填充为相同,名称为block1(输入)
层+=1
打印('Layer'+str(Layer)+'的输出形状是,'+str(x.get_shape()))
x=Conv2D(64,(3,3),数据格式为通道优先,激活为relu,填充为相同,名称为block1\u conv2’(x)
层+=1
打印('Layer'+str(Layer)+'的输出形状是,'+str(x.get_shape()))
x=MaxPooling2D((2,2),跨步=(2,2),name='block1_pool')(x)
#############
##第2区##
#############
x=Conv2D(128,(3,3),数据格式为通道优先,激活为relu,填充为相同,名称为block2\u conv1’(x)
层+=1
打印('Layer'+str(Layer)+'的输出形状是,'+str(x.get_shape()))
x=Conv2D(128,(3,3),数据格式为通道优先,激活为relu,填充为相同,名称为block2(conv2))(x)
层+=1
打印('Layer'+str(Layer)+'的输出形状是,'+str(x.get_shape()))
x=MaxPooling2D((2,2),跨步=(2,2),name='block2_pool')(x)
#############
##第3区##
#############
x=Conv2D(256,(3,3),数据格式为通道优先,激活为relu,填充为same,名称为block3(conv1))(x)
层+=1
打印('Layer'+str(Layer)+'的输出形状是,'+str(x.get_shape()))
x=Conv2D(256,(3,3),数据格式为通道优先,激活为relu,填充为相同,名称为block3\u conv2’(x)
层+=1
打印('Layer'+str(Layer)+'的输出形状是,'+str(x.get_shape()))
x=Conv2D(256,(3,3),数据格式为通道优先,激活为relu,填充为相同,名称为block3(x)
层+=1
打印('Layer'+str(Layer)+'的输出形状是,'+str(x.get_shape()))
x=MaxPooling2D((2,2),跨步=(2,2),name='block3_pool')(x)
#############
##第4区##
#############
x=Conv2D(512,(3,3),数据格式为通道优先,激活为relu,填充为相同,名称为block4\u conv1’(x)
层+=1
打印('Layer'+str(Layer)+'的输出形状是,'+str(x.get_shape()))
x=Conv2D(512,(3,3),数据格式为通道优先,激活为relu,填充为相同,名称为block4\u conv2’(x)
层+=1
打印('Layer'+str(Layer)+'的输出形状是,'+str(x.get_shape()))
x=Conv2D(512,(3,3),数据格式为通道优先,激活为relu,填充为相同,名称为block4\u conv3’(x)
层+=1
打印('Layer'+str(Layer)+'的输出形状是,'+str(x.get_shape()))
x=MaxPooling2D((2,2),跨步=(2,2),name='block4_pool')(x)
#############
##第5区##
#############
x=Conv2D(512,(3,3),数据格式为通道优先,激活为relu,填充为相同,名称为block5\u conv1’(x)
层+=1
打印('Layer'+str(Layer)+'的输出形状是,'+str(x.get_shape()))
x=Conv2D(512,(3,3),数据格式为通道优先,激活为relu,填充为相同,名称为block5\u conv2’(x)
层+=1
打印('Layer'+str(Layer)+'的输出形状是,'+str(x.get_shape()))
x=Conv2D(512,(3,3),数据格式为通道优先,激活为relu,填充为相同,名称为block5\u conv3’(x)
层+=1
打印('Layer'+str(Layer)+'的输出形状是,'+str(x.get_shape()))
out=MaxPooling2D((2,2),步长=(2,2