MCPcopy Create free account
hub / github.com/tensorflow/tfjs-examples / updateWeightDescription

Function updateWeightDescription

boston-housing/ui.js:42–67  ·  view source on GitHub ↗
(weightsList)

Source from the content-addressed store, hash-verified

40 * 'description':string
41 */
42export function updateWeightDescription(weightsList) {
43 const inspectionHeadlineElement =
44 document.getElementById('inspectionHeadline');
45 inspectionHeadlineElement.innerText =
46 `Top ${NUM_TOP_WEIGHTS_TO_DISPLAY} weights by magnitude`;
47 // Sort weights objects by descending absolute value.
48 weightsList.sort((a, b) => Math.abs(b.value) - Math.abs(a.value));
49 var table = document.getElementById('myTable');
50 // Clear out table contents
51 table.innerHTML = '';
52 // Add new rows to table.
53 weightsList.forEach((weight, i) => {
54 if (i < NUM_TOP_WEIGHTS_TO_DISPLAY) {
55 let row = table.insertRow(-1);
56 let cell1 = row.insertCell(0);
57 let cell2 = row.insertCell(1);
58 if (weight.value < 0) {
59 cell2.setAttribute('class', 'negativeWeight');
60 } else {
61 cell2.setAttribute('class', 'positiveWeight');
62 }
63 cell1.innerHTML = weight.description;
64 cell2.innerHTML = weight.value.toFixed(4);
65 }
66 });
67};
68
69export async function setup() {
70 const trainSimpleLinearRegression = document.getElementById('simple-mlr');

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected