本文整理匯總了Python中tracker.Tracker.get_state方法的典型用法代碼示例。如果您正苦於以下問題:Python Tracker.get_state方法的具體用法?Python Tracker.get_state怎麽用?Python Tracker.get_state使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tracker.Tracker
的用法示例。
在下文中一共展示了Tracker.get_state方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: compute_gradient
# 需要導入模塊: from tracker import Tracker [as 別名]
# 或者: from tracker.Tracker import get_state [as 別名]
def compute_gradient((model, dialog, n_data, )):
print 'here'
return 1
tracker = Tracker(model)
tracker.new_dialog()
last_state = tracker.get_state()
accum_loss_grad = []
for shape in model.shapes:
accum_loss_grad.append(np.zeros(shape, dtype=theano.config.floatX))
total_loss = 0.0
for act in dialog:
act_ndx = model.acts[act]
# Run tracker to get the new state and the true state.
curr_state, true_state = tracker.next(act)
# Compute the loss & gradient of the loss.
val = [model.values[true_state[slot]] for slot in model.slots]
total_loss += model.f_curr_slot_loss(curr_state, val)
for param_loss_grad, accum in zip(model.loss_grads, accum_loss_grad):
accum += 1.0 / n_data * param_loss_grad(last_state, act_ndx, val)
last_state = curr_state
return accum_loss_grad, total_loss