正文
{MODELNAME}/epoch_{e}_loss.png ,
f ..
/visuals/
{MODELNAME}/epoch_{e}_iter_{i}.png
]
)
# note that weattach two images here, the loss plot and
# ...a generated image output from our model
notify.send(msg)
# we then send the message
每隔100个epoch,就会发送一封包含上述所有内容的电子邮件。以下是其中一封邮件:
数据处理和传输
这点不是很有趣,但在时间消耗方面,它排第一名。
以使用Python将批量数据上传到SQLServer为例(对于没有BULK INSERT的人)。在上传脚本的最后,会有一个简单的消息通知上传完成。
import os
import notify
from data importSql # seehttps://jamescalam.github.io/pysqlplus/lib/data/sql.html
dt =Sql( database123 , server001 ) # setup theconnection to SQL Server
for i, file inenumerate(os.listdir( ../data/new )):
dt.push_raw(f ../data/new/{file} ) # push a file to SQL Server
# once the upload is complete, send a notification
# first we create the message
msg = notify.message(
subject= SQL Data Upload ,
text=f Data upload complete, {i} filesuploaded. ,
)
# send the message
notify.send(msg)
如果偶尔抛出错误,还可以添加一个try-except语句来捕获错误,并将其添加到一个列表中,以包含在更新和/或完成电子邮件中。
金融模型
金融建模中运行的所有东西实际上都非常快,所以此处只能提供一个示例。
以 现金流动模型工具 为例。现实中,这个过程只需要10-20秒,但现在假设你是华尔街炙手可热的定量分析师,正在处理几百万笔贷款。在这封电子邮件中,可能想要包含一个高级概要分析的投资组合。可以随机选择一些贷款,并在给定的时间段内可视化关键值——给定一个小样本来交叉检验模型的性能。
end = datetime.datetime.now() # get the ending datetime
# get the total runtime in hours:minutes:seconds
hours,rem =divmod((end - start).seconds, 3600)
mins,secs =divmod(rem, 60)
runtime= {:02d}:{:02d}:{:02