Beispiel #1
0
		valid_costs.append(ev_total_cost)

		# Plot and summarize
		values = {	'nepochs':count, 
					'has_any_valid_set': True,
					'tr_total_cost':tr_total_cost, 
					'ev_total_cost':ev_total_cost,
					'tr_recon_cost':tr_recon_cost, 
					'ev_recon_cost':ev_recon_cost,
					'tr_kl_cost':tr_kl_cost, 
					'ev_kl_cost':ev_kl_cost,
					'l2_weight':l2_weight, 
					'kl_weight':kl_weight,
					'l2_cost':l2_cost
				}
		model.summarize_all(datasets, values)

		# Manage learning rate.        
		n_lr = hps.learning_rate_n_to_compare        
		if len(train_costs) > n_lr and tr_total_cost > np.max(train_costs[-n_lr:]):            
			lr = session.run(model.learning_rate_decay_op)            
			print("     Decreasing learning rate to %f." % lr)
			# Force the system to run n_lr times while at this lr.
			train_costs.append(np.inf)
		else:
			train_costs.append(tr_total_cost)

		if lr < lr_stop:
			print("Stopping optimization based on learning rate criteria.")
			break
Beispiel #2
0
		valid_costs.append(ev_total_cost)

		# Plot and summarize
		values = {	'nepochs':count, 
					'has_any_valid_set': True,
					'tr_total_cost':tr_total_cost, 
					'ev_total_cost':ev_total_cost,
					'tr_recon_cost':tr_recon_cost, 
					'ev_recon_cost':ev_recon_cost,
					'tr_kl_cost':tr_kl_cost, 
					'ev_kl_cost':ev_kl_cost,
					'l2_weight':l2_weight, 
					'kl_weight':kl_weight,
					'l2_cost':l2_cost
				}
		model.summarize_all(data, values)

		# Manage learning rate.        
		n_lr = hps.learning_rate_n_to_compare        
		if len(train_costs) > n_lr and tr_total_cost > np.max(train_costs[-n_lr:]):            
			lr = session.run(model.learning_rate_decay_op)            
			print("     Decreasing learning rate to %f." % lr)
			# Force the system to run n_lr times while at this lr.
			train_costs.append(np.inf)
		else:
			train_costs.append(tr_total_cost)

		if lr < lr_stop:
			print("Stopping optimization based on learning rate criteria.")
			break