<commit_before>/**
 * Don't ask for confirmation before reloading
 * or leaving the page.
 */
window.onbeforeunload = function() { return true; }

/**
 * The current training epoch number.
 * @type {Number}
 */
var curr_epoch = 0;

/**
 * The currently training RBM number index.
 * @type {Number}
 */
var curr_rbm = -1;

/**
 * A unique identifier for the training
 * job running on the server.
 * @type {String}
 */
var job_id = undefined;

/**
 * The chart for plotting the reconstruction
 * error over time, while training the net.
 * @type {Highcharts.Chart}
 */
var chart = undefined;

/**
 * Updates the architecture form after
 * after the `tab` key is pressed but
 * _before_ its default behaviour is applied.
 */
$(function() {
	$('#net_form').keydown(function (e) {
		if (e.which == 8) updateArchitecture();
	});
});

/**
 * Prevents the submission of the form
 * when the `enter` key is pressed.
 */
$(function() {
	$('#train_form').keydown(function (e) {
		if (e.which == 13) e.preventDefault();
	});
});

/**
 * Updates the form for defining the DBN layers,
 * based on the number of layers that the user
 * wants to create.
 */
function updateArchitecture() {
	var num_layers = $('#num_layers').val();
	if (num_layers == '')
		return;
	if (num_layers < 1) {
		alert('You must have at least one layer (the visible layer): defaulting to 1.');
		$('#num_layers').val(1);
		num_layers = 1;
	}
	if (num_layers > 6) {
		alert('Too many layers (' + num_layers + '): defaulting to 6.');
		$('#num_layers').val(6);
		num_layers = 6;
	}

	// how many HTML inputs do we already have?
	var curr_layers = $('.lay_sz').length;

	// add missing hidden layers:
	for (var i = curr_layers; i < num_layers; i++)
		$('#layers_sz').append('<li class="lay_sz"><input type="text" name="hid_sz_' + i + '" id="hid_sz_' + i + '" onchange="updateGraph();" /></li>');

	// remove exceeding hidden layers:
	for (var i = curr_layers; i > num_layers; i--)
		$('.lay_sz').last().remove();
}

/**
 * Returns a standard string identifier
 * for the given node in the given layer.
 * @param  {Number} layer the layer position in the DBN
 * @param  {Number} node  the node position in the layer
 * @return {String}       a string identifier
 */
function nodeId(layer, node) {
	return 'l' + layer + 'n' + node;
}

/**
 * Returns a standard string identifier
 * for the given edge in the network graph.
 * @param  {Number} node1 the identifier for the first node
 * @param  {Number} node2 the identifier for the second node
 * @return {String}       a string identifier
 */
function edgeId(node1, node2) {
	return node1 + '_' + node2;
}

/**
 * Returns the logarithm of `x` base `base`.
 * @param  {Number} x    the argument of the logarithm
 * @param  {Number} base the base
 * @return {Number}      log_base(x)
 */
function baseLog(x, base) {
	return Math.log(x) / Math.log(base);
}

/**
 * Repaints the Cytoscape graph, checking
 * for changes in the HTML form.
 */
function updateGraph() {
	var num_layers = $('#num_layers').val();
	var prec_layer_nodes = 0;
	var networkGraph = cytoscape({
		container: document.getElementById('DBNgraph')
	});

	// gather new nodes and edges:
	var graphElements = [];
	for (var layer = 0; layer < num_layers; layer++) {
		var num_nodes = 0;
		var label;
		var selector;
		var parent = undefined;

		if (layer == 0) {
			num_nodes = $('#vis_sz').val();
			label = 'visible layer';
			selector = $('#vis_sz');
		} else {
			num_nodes = $('#hid_sz_' + layer).val();
			label = 'hidden layer ' + layer;
			selector = $('#hid_sz_' + layer);
		}

		if (num_nodes != '' && num_nodes > 0) {
			var max_real_nodes = 10000;
			var max_visible_nodes = 40;
			var max_rendered_nodes = 80;

			if (num_nodes > max_real_nodes) {
				alert('Too many nodes at ' + label + ' (' + num_nodes + ' nodes!): aborting; defaulting to ' + max_real_nodes + '.');
				selector.val(max_real_nodes);
				return;
			}

			if (num_nodes > max_visible_nodes) {<commit_msg>Minor update UI<commit_after>/**
 * Don't ask for confirmation before reloading
 * or leaving the page.
 */
window.onbeforeunload = function() { return true; }

/**
 * The current training epoch number.
 * @type {Number}
 */
var curr_epoch = 0;

/**
 * The currently training RBM number index.
 * @type {Number}
 */
var curr_rbm = -1;

/**
 * A unique identifier for the training
 * job running on the server.
 * @type {String}
 */
var job_id = undefined;

/**
 * The chart for plotting the reconstruction
 * error over time, while training the net.
 * @type {Highcharts.Chart}
 */
var chart = undefined;

/**
 * Updates the architecture form after
 * after the `tab` key is pressed but
 * _before_ its default behaviour is applied.
 */
$(function() {
	$('#net_form').keydown(function (e) {
		if (e.which == 8) updateArchitecture();
	});
});

/**
 * Prevents the submission of the form
 * when the `enter` key is pressed.
 */
$(function() {
	$('#train_form').keydown(function (e) {
		if (e.which == 13) e.preventDefault();
	});
});

/**
 * Updates the form for defining the DBN layers,
 * based on the number of layers that the user
 * wants to create.
 */
function updateArchitecture() {
	var num_layers = $('#num_layers').val();
	if (num_layers == '')
		return;
	if (num_layers < 1) {
		alert('You must have at least one layer (the visible layer): defaulting to 1.');
		$('#num_layers').val(1);
		num_layers = 1;
	}
	if (num_layers > 6) {
		alert('Too many layers (' + num_layers + '): defaulting to 6.');
		$('#num_layers').val(6);
		num_layers = 6;
	}

	// how many HTML inputs do we already have?
	var curr_layers = $('.lay_sz').length;

	// add missing hidden layers:
	for (var i = curr_layers; i < num_layers; i++)
		$('#layers_sz').append('<li class="lay_sz"><input type="text" name="hid_sz_' + i + '" id="hid_sz_' + i + '" onchange="updateGraph();" /></li>');

	// remove exceeding hidden layers:
	for (var i = curr_layers; i > num_layers; i--)
		$('.lay_sz').last().remove();
}

/**
 * Returns a standard string identifier
 * for the given node in the given layer.
 * @param  {Number} layer the layer position in the DBN
 * @param  {Number} node  the node position in the layer
 * @return {String}       a string identifier
 */
function nodeId(layer, node) {
	return 'l' + layer + 'n' + node;
}

/**
 * Returns a standard string identifier
 * for the given edge in the network graph.
 * @param  {Number} node1 the identifier for the first node
 * @param  {Number} node2 the identifier for the second node
 * @return {String}       a string identifier
 */
function edgeId(node1, node2) {
	return node1 + '_' + node2;
}

/**
 * Returns the logarithm of `x` base `base`.
 * @param  {Number} x    the argument of the logarithm
 * @param  {Number} base the base
 * @return {Number}      log_base(x)
 */
function baseLog(x, base) {
	return Math.log(x) / Math.log(base);
}

/**
 * Repaints the Cytoscape graph, checking
 * for changes in the HTML form.
 */
function updateGraph() {
	var num_layers = $('#num_layers').val();
	var prec_layer_nodes = 0;
	var networkGraph = cytoscape({
		container: document.getElementById('DBNgraph')
	});

	// gather new nodes and edges:
	var graphElements = [];
	for (var layer = 0; layer < num_layers; layer++) {
		if (layer == 0) {
			var label = 'visible layer';
			var selector = $('#vis_sz');
		} else {
			var label = 'hidden layer ' + layer;
			var selector = $('#hid_sz_' + layer);
		}
		var num_nodes = selector.val()

		if (num_nodes != '' && num_nodes > 0) {
			var max_real_nodes = 10000;
			var max_visible_nodes = 40;
			var max_rendered_nodes = 80;

			if (num_nodes > max_real_nodes) {
				alert('Too many nodes at ' + label + ' (' + num_nodes + ' nodes!): aborting; defaulting to ' + max_real_nodes + '.');
				selector.val(max_real_nodes);
				return;
			}

			var parent = undefined;
			if (num_nodes > max_visible_nodes) {
{'fraction_non_alphanumeric': 0.15254020934388562, 'fraction_numerical': 0.008297166198621394, 'mean_word_length': 3.4466515323496028, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2251925', 'n_tokens_mistral': 2723, 'n_tokens_neox': 2568, 'n_words': 863}