【エラー解決】AttributeError: module 'tensorflow.train' has no attribute 'SummaryWriter',TensorFlow

TensorFlowのTensorBoardを使う際に起きるエラー。

たとえば、

session = tf.Session()
tw = tf.train.SummaryWriter("sample_dir", graph=session.graph)

などとした場合、

AttributeError: module 'tensorflow.train' has no attribute 'SummaryWriter'

と出る。

結論を言えば、書き換えればいいだけ。
tw = tf.summary.FileWriter("log_dir", graph=session.graph)

他にも書き換えねばならない関数たちがあります。
以下の記事がよくまとめられているので、ご参照ください。
TensorFlow の "AttributeError: 'module' object has no attribute 'xxxx'" エラーでつまづいてしまう人のための移行ガイド