0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

jupyter notebookでtensorflow_federatedを動かす

0
Last updated at Posted at 2020-10-20

jupyter notebookでtensorflowを使えるようにする

フェデレーティッドラーニングをjupyter notebook上で使いたかったので環境構築しました。
その手順の備忘録です。

参考にしたサイト

諸々のインストール

  • tensorflow_federatedはtensorflowのバージョン2.2.0以下で動作するため、以前にインストールしたtensorflow関連のものをアンインストールしてから再インストールする
pip uninstall tb-nightly tensorboard tensorflow tensorflow-estimator tf-estimator-nightly tf-nightly
pip install tensorflow==2.2.0rc0 
  • jupyter notebookの環境構築手順
conda create -n FL python=3.6
(conda init zsh)  # 以前はbashを使用していたがzshに移行したので、initしろと表示が出たのでしたがった
conda activate FL
conda install jupyter
# 上記の手順でインストールしてたら飛ばしてください
pip install tensorflow==2.2.0rc0
(最新は2.3.1だがfederatedが動くのは2.2.0以下)

jupyter notebook

# jupyter notebook上で実行
!pip install --quiet --upgrade tensorflow_federated_nightly
!pip install --quiet --upgrade nest_asyncio

installが正常に行えたか確認するための処理

import nest_asyncio
nest_asyncio.apply()

%load_ext tensorboard

import collections

import numpy as np
import tensorflow as tf
import tensorflow_federated as tff

np.random.seed(0)

tff.federated_computation(lambda: 'Hello, World!')()
# print(tff.federated_computation(lambda: 'Hello, World!')())
 

 b'Hello, World!'が返ってきたら成功です

チュートリアルを進めてたらエラーが発生

tensroboradを読み込む際に、Duplicate pluginsというエラーが発生。
tensorflowを再インストールすることで解決した。

pip uninstall tb-nightly tensorboard tensorflow tensorflow-estimator tf-estimator-nightly tf-nightly
pip install tensorflow==2.2.0rc0 
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?