本文整理汇总了Python中keras.backend.set_session方法的典型用法代码示例。如果您正苦于以下问题:Python backend.set_session方法的具体用法?Python backend.set_session怎么用?Python backend.set_session使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在模块keras.backend的用法示例。
在下文中一共展示了backend.set_session方法的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
点赞 6
# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import set_session [as 别名]
def __init__(self, train_df, word_count, batch_size, epochs):
tf.set_random_seed(4)
session_conf = tf.ConfigProto(intra_op_parallelism_threads=2, inter_op_parallelism_threads=8)
backend.set_session(tf.Session(graph=tf.get_default_graph(), config=session_conf))
self.batch_size = batch_size
self.epochs = epochs
self.max_name_seq = 10
self.max_item_desc_seq = 75
self.max_text = word_count + 1
self.max_brand = np.max(train_df.brand_name.max()) + 1
self.max_condition = np.max(train_df.item_condition_id.max()) + 1
self.max_subcat0 = np.max(train_df.subcat_0.max()) + 1
self.max_subcat1 = np.max(train_df.subcat_1.max()) + 1
self.max_subcat2 = np.max(train_df.subcat_2.max()) + 1
开发者ID:aerdem4,项目名称:mercari-price-suggestion,代码行数:18,
示例2: __init__
点赞 6
# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import set_session [as 别名]
def __init__(self, action_size):
# environment settings
self.state_size = (84, 84, 4)
self.action_size = action_size
self.discount_factor = 0.99
self.no_op_steps = 30
# optimizer parameters
self.actor_lr = 2.5e-4
self.critic_lr = 2.5e-4
self.threads = 8
# create model for actor and critic network
self.actor, self.critic = self.build_model()
# method for training actor and critic network
self.optimizer = [self.actor_optimizer(), self.critic_optimizer()]
self.sess = tf.InteractiveSession()
K.set_session(self.sess)
self.sess.run(tf.global_variables_initializer())
self.summary_placeholders, self.update_ops, self.summary_op = self.setup_summary()
self.summary_writer = tf.summary.FileWriter('summary/breakout_a3c', self.sess.graph)
开发者ID:rlcode,项目名称:reinforcement-learning,代码行数:27,
示例3: __init__
点赞 6
# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import set_session [as 别名]
def __init__(self, sess, state_size, action_size, DDPG_config):
self.HIDDEN1_UNITS = DDPG_config['HIDDEN1_UNITS']
self.HIDDEN2_UNITS = DDPG_config['HIDDEN2_UNITS']
self.sess = sess
self.BATCH_SIZE = DDPG_config['BATCH_SIZE']
self.TAU = DDPG_config['TAU']
self.LEARNING_RATE = DDPG_config['LRC']
self.action_size = action_size
self.h_acti = relu
if DDPG_config['HACTI'] == 'selu':
self.h_acti = selu
K.set_session(sess)
#Now create the model
self.model, self.action, self.state = self.create_critic_network(state_size, action_size)
self.target_model, self.target_action, self.target_state = self.create_critic_network(state_size, action_size)
self.action_grads = tf.gradients(self.model.output, self.action) #GRADIENTS for policy update
self.sess.run(tf.global_variables_initializer())
开发者ID:knowledgedefinednetworking,项目名称:a-deep-rl-approach-for-sdn-routing-optimization,代码行数:23,
示例4: set_session_config
点赞 6
# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import set_session [as 别名]
def set_session_config(per_process_gpu_memory_fraction=None, allow_growth=None):
"""
:param allow_growth: When necessary, reserve memory
:param float per_process_gpu_memory_fraction: specify GPU memory usage as 0 to 1
:return:
"""
import tensorflow as tf
import keras.backend as K
config = tf.ConfigProto(
gpu_options=tf.GPUOptions(
per_process_gpu_memory_fraction=per_process_gpu_memory_fraction,
allow_growth=allow_growth,
)
)
sess = tf.Session(config=config)
K.set_session(sess)
开发者ID:Zeta36,项目名称:connect4-alpha-zero,代码行数:21,
示例5: prepare_model
点赞 6
# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import set_session [as 别名]
def prepare_model(self):
"""Prepares the model for training."""
# Set the Keras directory.
set_keras_base_directory()
if K.backend() == 'tensorflow':
# set GPU option allow_growth to False for GPU-enabled tensorflow
config = tf.ConfigProto()
config.gpu_options.allow_growth = False
sess = tf.Session(config=config)
K.set_session(sess)
# Deserialize the Keras model.
self.model = deserialize_keras_model(self.model)
self.optimizer = deserialize(self.optimizer)
# Compile the model with the specified loss and optimizer.
self.model.compile(loss=self.loss, loss_weights = self.loss_weights,
optimizer=self.optimizer, metrics=self.metrics)
开发者ID:cerndb,项目名称:dist-keras,代码行数:19,
示例6: __init__
点赞 6
# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import set_session [as 别名]
def __init__(self, sess, state_size, action_size, BATCH_SIZE, TAU, LEARNING_RATE, convolutional=False, output_activation='sigmoid'):
self.sess = sess
self.BATCH_SIZE = BATCH_SIZE
self.TAU = TAU
self.LEARNING_RATE = LEARNING_RATE
self.convolutional = convolutional
self.output_activation = output_activation
#K.set_session(sess)
#Now create the model
self.model , self.weights, self.state = self.create_actor_network(state_size, action_size)
self.target_model, self.target_weights, self.target_state = self.create_actor_network(state_size, action_size)
self.action_gradient = tf.placeholder(tf.float32,[None, action_size])
self.params_grad = tf.gradients(self.model.output, self.weights, -self.action_gradient)
grads = zip(self.params_grad, self.weights)
self.optimize = tf.train.AdamOptimizer(LEARNING_RATE).apply_gradients(grads)
init_op = tf.global_variables_initializer()
self.sess.run(init_op)
开发者ID:jhu-lcsr,项目名称:costar_plan,代码行数:21,
示例7: __init__
点赞 6
# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import set_session [as 别名]
def __init__(self, sess, state_size, action_size, BATCH_SIZE, TAU, LEARNING_RATE, convolutional=False):
self.sess = sess
self.BATCH_SIZE = BATCH_SIZE
self.TAU = TAU
self.LEARNING_RATE = LEARNING_RATE
self.action_size = action_size
self.convolutional = convolutional
#K.set_session(sess)
#Now create the model
self.model, self.action, self.state = self.create_critic_network(state_size, action_size)
self.target_model, self.target_action, self.target_state = self.create_critic_network(state_size, action_size)
self.action_grads = tf.gradients(self.model.output, self.action) #GRADIENTS for policy update
init_op = tf.global_variables_initializer()
self.sess.run(init_op)
开发者ID:jhu-lcsr,项目名称:costar_plan,代码行数:18,
示例8: ConfigureGPU
点赞 6
# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import set_session [as 别名]
def ConfigureGPU(args):
cpu = True if 'cpu' in args and args['cpu'] else False
fraction = 1
if 'gpu_fraction' in args and args['gpu_fraction']:
fraction = args['gpu_fraction']
if fraction < 1. or cpu:
import tensorflow as tf
import keras.backend as K
if cpu:
config = tf.ConfigProto(
device_count={'GPU': 0}
)
sess = tf.Session(config=config)
else:
gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=fraction)
sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options))
K.set_session(sess)
开发者ID:jhu-lcsr,项目名称:costar_plan,代码行数:22,
示例9: parallel_gpu_jobs
点赞 6
# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import set_session [as 别名]
def parallel_gpu_jobs(allow_growth=True, fraction=.5):
'''Sets the max used memory as a fraction for tensorflow
backend
allow_growth :: True of False
fraction :: a float value (e.g. 0.5 means 4gb out of 8gb)
'''
import keras.backend as K
import tensorflow as tf
gpu_options = tf.GPUOptions(allow_growth=allow_growth,
per_process_gpu_memory_fraction=fraction)
config = tf.ConfigProto(gpu_options=gpu_options)
session = tf.Session(config=config)
K.set_session(session)
开发者ID:autonomio,项目名称:talos,代码行数:21,
示例10: init_devices
点赞 6
# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import set_session [as 别名]
def init_devices(device_type=None):
if device_type is None:
device_type = 'cpu'
num_cores = 4
if device_type == 'gpu':
num_GPU = 1
num_CPU = 1
else:
num_CPU = 1
num_GPU = 0
config = tf.ConfigProto(intra_op_parallelism_threads=num_cores,
inter_op_parallelism_threads=num_cores, allow_soft_placement=True,
device_count={'CPU': num_CPU, 'GPU': num_GPU})
session = tf.Session(config=config)
K.set_session(session)
开发者ID:chen0040,项目名称:keras-text-summarization,代码行数:20,
示例11: __start_train_model_on_video_frames_videograph
点赞 6
# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import set_session [as 别名]
def __start_train_model_on_video_frames_videograph(n_epochs, n_timesteps, n_centroids, timestamp, is_resume_training, start_epoch_num):
# configure the gpu to be used by keras
gpu_core_id = 3
device_id = '/gpu:%d' % gpu_core_id
# with graph.as_default():
# with session.as_default():
graph = tf.Graph()
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
config.allow_soft_placement = True
sess = tf.Session(config=config, graph=graph)
K.set_session(sess)
with sess:
with tf.device(device_id):
__train_model_on_video_frames_videograph(n_epochs, n_timesteps, n_centroids, timestamp, is_resume_training, start_epoch_num)
开发者ID:noureldien,项目名称:videograph,代码行数:19,
示例12: __start_train_model_on_video_frames_backbone_i3d_keras
点赞 6
# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import set_session [as 别名]
def __start_train_model_on_video_frames_backbone_i3d_keras(n_epochs, starting_epoch_num, n_frames_per_video, n_instances, instance_num):
# configure the gpu to be used by keras
gpu_core_id = instance_num - 1
device_id = '/gpu:%d' % gpu_core_id
assert instance_num in [1, 2, 3], 'Sorry, wrong instance number: %d' % (instance_num)
graph = tf.Graph()
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
config.allow_soft_placement = True
sess = tf.Session(config=config, graph=graph)
K.set_session(sess)
with sess:
with tf.device(device_id):
__train_model_on_video_frames_backbone_i3d_keras(n_epochs, starting_epoch_num, n_frames_per_video, n_instances, instance_num)
开发者ID:noureldien,项目名称:videograph,代码行数:18,
示例13: configure_hardware
点赞 6
# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import set_session [as 别名]
def configure_hardware(RAND_SEED):
'''configure rand seed, GPU'''
from keras import backend as K
if K.backend() == 'tensorflow':
K.tf.set_random_seed(RAND_SEED)
else:
K.theano.tensor.shared_randomstreams.RandomStreams(seed=RAND_SEED)
if K.backend() != 'tensorflow':
# GPU config for tf only
return
process_num = PARALLEL_PROCESS_NUM if args.param_selection else 1
tf = K.tf
gpu_options = tf.GPUOptions(
allow_growth=True,
per_process_gpu_memory_fraction=1./float(process_num))
config = tf.ConfigProto(
gpu_options=gpu_options,
allow_soft_placement=True)
sess = tf.Session(config=config)
K.set_session(sess)
return sess
开发者ID:kengz,项目名称:openai_lab,代码行数:25,
示例14: build_model
点赞 6
# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import set_session [as 别名]
def build_model(self, local_session = True):
import keras.backend as K
if local_session:
graph = K.tf.Graph()
session = K.tf.Session(graph=graph, config=K.tf.ConfigProto(
allow_soft_placement=True, log_device_placement=False,
gpu_options=K.tf.GPUOptions(
per_process_gpu_memory_fraction=1./self.comm.Get_size()) ) )
with graph.as_default():
with session.as_default():
import keras.backend as K
ret_model = self.build_model_aux()
ret_model.session = session
ret_model.graph = graph
return ret_model
else:
K.set_session( K.tf.Session( config=K.tf.ConfigProto(
allow_soft_placement=True, log_device_placement=False,
gpu_options=K.tf.GPUOptions(
per_process_gpu_memory_fraction=1./self.comm.Get_size()) ) ) )
return self.build_model_aux()
开发者ID:vlimant,项目名称:mpi_learn,代码行数:25,
示例15: __init__
点赞 6
# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import set_session [as 别名]
def __init__(self, nfeatures=50, arch=[8, 'act', 8, 'act'], fine_tune_layers=[2, 3], batch_size=16,
val_data=None, validate_every=1, activations='relu', epochs=5000, epochs_finetune=5000, optimizer=None, optimizer_finetune=None,
noise=0.0, droprate=0.0, verbose=True, stop_at_target_loss=0):
self.batch_size = batch_size
self.validate_every = validate_every
self.epochs = epochs
self.epochs_finetune = epochs_finetune
self.verbose = verbose
self.stop_at_target_loss = stop_at_target_loss
if val_data is None:
self.validate_every = 0
else:
self.Xval = val_data[0]
self.yval = val_data[1]
self._build_model(nfeatures, arch, activations, noise, droprate, optimizer, optimizer_finetune, fine_tune_layers)
self.sess = tf.Session()
K.set_session(self.sess)
self.sess.run(tf.global_variables_initializer())
开发者ID:erlendd,项目名称:ddan,代码行数:23,
示例16: __init__
点赞 6
# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import set_session [as 别名]
def __init__(self, nfeatures=50, arch=[8, 'act'], coral_layer_idx=[1],
batch_size=16, supervised=False, confusion=1e4, confusion_incr=50, confusion_max=1e9,
val_data=None, validate_every=1,
activations='relu', epochs=1000, optimizer=None, noise=0.0, droprate=0.0, verbose=True):
self.batch_size = batch_size
self.epochs = epochs
self.validate_every = validate_every
self.supervised = supervised
self.verbose = verbose
if val_data is None:
self.validate_every = 0
else:
self.Xval = val_data[0]
self.yval = val_data[1]
self._build_model(nfeatures, arch, supervised, confusion, confusion_incr,
confusion_max, activations, noise, droprate, coral_layer_idx, optimizer)
self.sess = tf.Session()
K.set_session(self.sess)
self.sess.run(tf.global_variables_initializer())
开发者ID:erlendd,项目名称:ddan,代码行数:25,
示例17: __init__
点赞 6
# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import set_session [as 别名]
def __init__(self, nfeatures=50, arch_shared=[32, 'act'], arch_domain=[8, 'act'], arch_clf=[],
batch_size=16, supervised=False, val_data=None, validate_every=1,
activations='relu', epochs=1000, optimizer=None, noise=0.0, droprate=0.0, stop_at_target_loss=0.0):
self.batch_size = batch_size
self.epochs = epochs
self.validate_every = validate_every
self.stop_at_target_loss = stop_at_target_loss
if val_data is None:
validate_every = 0
else:
self.Xval = val_data[0]
self.yval = val_data[1]
self._build_model(nfeatures, arch_shared, arch_domain, arch_clf,
activations, supervised, noise, droprate, optimizer)
self.sess = tf.Session()
K.set_session(self.sess)
self.sess.run(tf.global_variables_initializer())
开发者ID:erlendd,项目名称:ddan,代码行数:23,
示例18: __init__
点赞 6
# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import set_session [as 别名]
def __init__(self, nfeatures=50, arch=[8, 'act'], mmd_layer_idx=[1],
batch_size=16, supervised=False, confusion=0.0, confusion_incr=1e-3, confusion_max=1,
val_data=None, validate_every=1,
activations='relu', epochs=1000, optimizer=None, noise=0.0, droprate=0.0, verbose=True):
self.batch_size = batch_size
self.epochs = epochs
self.validate_every = validate_every
self.supervised = supervised
self.verbose = verbose
if val_data is None:
self.validate_every = 0
else:
self.Xval = val_data[0]
self.yval = val_data[1]
self._build_model(nfeatures, arch, supervised, confusion, confusion_incr,
confusion_max, activations, noise, droprate, mmd_layer_idx, optimizer)
self.sess = tf.Session()
K.set_session(self.sess)
self.sess.run(tf.global_variables_initializer())
开发者ID:erlendd,项目名称:ddan,代码行数:25,
示例19: setup
点赞 5
# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import set_session [as 别名]
def setup(env):
stderr = sys.stderr
sys.stderr = open(os.devnull, "w")
# pylint: disable=W0612
try:
import keras
except Exception as e:
raise e
finally:
sys.stderr = stderr
from keras import backend as K
if K.backend() == 'tensorflow':
TensorFlowLibrary.setup(env)
K.set_session(TensorFlowLibrary.create_session(env))
开发者ID:mme,项目名称:vergeml,代码行数:17,
示例20: __enter__
点赞 5
# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import set_session [as 别名]
def __enter__(self):
# pylint: disable=attribute-defined-outside-init
self.old_session = K.get_session()
self.g = self.requested_graph or tf.Graph() # pylint: disable=invalid-name
self.current_session = tf.Session(graph=self.g)
# pylint: enable=attribute-defined-outside-init
K.set_session(self.current_session)
return self.current_session, self.g
开发者ID:databricks,项目名称:spark-deep-learning,代码行数:10,
示例21: __exit__
点赞 5
# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import set_session [as 别名]
def __exit__(self, exc_type, exc_val, exc_tb):
# Restore the previous session
K.set_session(self.old_session)
开发者ID:databricks,项目名称:spark-deep-learning,代码行数:5,
示例22: __enter__
点赞 5
# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import set_session [as 别名]
def __enter__(self):
self.sess.__enter__()
if self.using_keras:
K.set_session(self.sess)
return self
开发者ID:databricks,项目名称:spark-deep-learning,代码行数:7,
示例23: __exit__
点赞 5
# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import set_session [as 别名]
def __exit__(self, *args):
if self.using_keras:
K.set_session(self.keras_prev_sess)
self.sess.__exit__(*args)
开发者ID:databricks,项目名称:spark-deep-learning,代码行数:6,
示例24: __init__
点赞 5
# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import set_session [as 别名]
def __init__(self, action_size):
self.render = False
self.load_model = False
# 상태와 행동의 크기 정의
self.state_size = (84, 84, 4)
self.action_size = action_size
# DQN 하이퍼파라미터
self.epsilon = 1.
self.epsilon_start, self.epsilon_end = 1.0, 0.1
self.exploration_steps = 1000000.
self.epsilon_decay_step = (self.epsilon_start - self.epsilon_end) \
/ self.exploration_steps
self.batch_size = 32
self.train_start = 50000
self.update_target_rate = 10000
self.discount_factor = 0.99
# 리플레이 메모리, 최대 크기 400000
self.memory = deque(maxlen=400000)
self.no_op_steps = 30
# 모델과 타겟모델을 생성하고 타겟모델 초기화
self.model = self.build_model()
self.target_model = self.build_model()
self.update_target_model()
self.optimizer = self.optimizer()
# 텐서보드 설정
self.sess = tf.InteractiveSession()
K.set_session(self.sess)
self.avg_q_max, self.avg_loss = 0, 0
self.summary_placeholders, self.update_ops, self.summary_op = \
self.setup_summary()
self.summary_writer = tf.summary.FileWriter(
'summary/breakout_dqn', self.sess.graph)
self.sess.run(tf.global_variables_initializer())
if self.load_model:
self.model.load_weights("./save_model/breakout_dqn.h5")
# Huber Loss를 이용하기 위해 최적화 함수를 직접 정의
开发者ID:rlcode,项目名称:reinforcement-learning-kr,代码行数:43,
示例25: __init__
点赞 5
# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import set_session [as 别名]
def __init__(self, action_size):
# 상태크기와 행동크기를 갖고옴
self.state_size = (84, 84, 4)
self.action_size = action_size
# A3C 하이퍼파라미터
self.discount_factor = 0.99
self.no_op_steps = 30
self.actor_lr = 2.5e-4
self.critic_lr = 2.5e-4
# 쓰레드의 갯수
self.threads = 8
# 정책신경망과 가치신경망을 생성
self.actor, self.critic = self.build_model()
# 정책신경망과 가치신경망을 업데이트하는 함수 생성
self.optimizer = [self.actor_optimizer(), self.critic_optimizer()]
# 텐서보드 설정
self.sess = tf.InteractiveSession()
K.set_session(self.sess)
self.sess.run(tf.global_variables_initializer())
self.summary_placeholders, self.update_ops, self.summary_op = \
self.setup_summary()
self.summary_writer = \
tf.summary.FileWriter('summary/breakout_a3c', self.sess.graph)
# 쓰레드를 만들어 학습을 하는 함수
开发者ID:rlcode,项目名称:reinforcement-learning-kr,代码行数:30,
示例26: __init__
点赞 5
# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import set_session [as 别名]
def __init__(self, action_size):
self.state_size = (84, 84, 4)
self.action_size = action_size
self.no_op_steps = 20
self.model = self.build_model()
self.sess = tf.InteractiveSession()
K.set_session(self.sess)
self.avg_q_max, self.avg_loss = 0, 0
self.sess.run(tf.global_variables_initializer())
开发者ID:rlcode,项目名称:reinforcement-learning-kr,代码行数:14,
示例27: __config_gpu_for_keras
点赞 5
# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import set_session [as 别名]
def __config_gpu_for_keras():
import tensorflow as tf
import keras.backend as K
gpu_core_id = __parse_gpu_id()
K.clear_session()
config = tf.ConfigProto()
config.gpu_options.visible_device_list = str(gpu_core_id)
config.gpu_options.allow_growth = True
session = tf.Session(config=config)
K.set_session(session)
# set which device to be used
const.GPU_CORE_ID = gpu_core_id
开发者ID:CMU-CREATE-Lab,项目名称:deep-smoke-machine,代码行数:17,
示例28: __init__
点赞 5
# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import set_session [as 别名]
def __init__(self, action_size):
self.render = False
self.load_model = False
# environment settings
self.state_size = (84, 84, 4)
self.action_size = action_size
# parameters about epsilon
self.epsilon = 1.
self.epsilon_start, self.epsilon_end = 1.0, 0.1
self.exploration_steps = 1000000.
self.epsilon_decay_step = (self.epsilon_start - self.epsilon_end) \
/ self.exploration_steps
# parameters about training
self.batch_size = 32
self.train_start = 50000
self.update_target_rate = 10000
self.discount_factor = 0.99
self.memory = deque(maxlen=400000)
self.no_op_steps = 30
# build
self.model = self.build_model()
self.target_model = self.build_model()
self.update_target_model()
self.optimizer = self.optimizer()
self.sess = tf.InteractiveSession()
K.set_session(self.sess)
self.avg_q_max, self.avg_loss = 0, 0
self.summary_placeholders, self.update_ops, self.summary_op = \
self.setup_summary()
self.summary_writer = tf.summary.FileWriter(
'summary/breakout_ddqn', self.sess.graph)
self.sess.run(tf.global_variables_initializer())
if self.load_model:
self.model.load_weights("./save_model/breakout_ddqn.h5")
# if the error is in [-1, 1], then the cost is quadratic to the error
# But outside the interval, the cost is linear to the error
开发者ID:rlcode,项目名称:reinforcement-learning,代码行数:43,
注:本文中的keras.backend.set_session方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。