1 Star 0 Fork 0

zhoub86/capacity-rl-po

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
example.py 1.35 KB
一键复制 编辑 原始数据 按行查看 历史
zivaharoni 提交于 2020-03-08 12:40 . initial commit of code
import tensorflow as tf
gpus = tf.config.experimental.list_physical_devices('GPU')
print("Num GPUs Available: ", len(tf.config.experimental.list_physical_devices('GPU')))
if gpus:
try:
# Currently, memory growth needs to be the same across GPUs
for gpu in gpus:
tf.config.experimental.set_memory_growth(gpu, True)
logical_gpus = tf.config.experimental.list_logical_devices('GPU')
print(len(gpus), "Physical GPUs,", len(logical_gpus), "Logical GPUs")
except RuntimeError as e:
# Memory growth must be set before GPUs have been initialized
print("MESSAGE", e)
from models.example_model import ActorModel, IsingModel
from algorithms.example_trainer import POTrainer
from utils.config import process_config
from utils.utils import get_args
def main():
# capture the config path from the run arguments
# then process the json configuration file
config = process_config(get_args())
# create an instance of the model you want
actor = ActorModel(config)
# create your data generator§
env = IsingModel(config)
# create tensorboard logger
# logger = Logger(config)
# create trainer and pass all the previous components to it
trainer = POTrainer(actor, env, config)
#load model if exists
# model.load(sess)
# here you train your model
trainer.train()
if __name__ == '__main__':
main()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhoub86/capacity-rl-po.git
git@gitee.com:zhoub86/capacity-rl-po.git
zhoub86
capacity-rl-po
capacity-rl-po
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385