import sys
import caffe
# let's say we'd like to redirect caffe's output to the file caffe-output.txt:
tmp = sys.stdout
sys.stdout = open('caffe-output.txt', 'wt')
# now everything sent to stdout will go to the file instead. Even 'print' commands.
net = caffe.Net('foo.prototxt', 'bar.caffemodel', caffe.TEST)
net.forward()
print 'Even this is written to the file!'
# reset the redirection
sys.stdout.close()
sys.stdout = tmp
# now everything's back to normal, a print will be written to the console again
print 'This is written to the real stdout again!'
$ caffe train -solver whatever.prototxt | tee output.txt