Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update C1_W1_Assignment.html #59

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
46 changes: 39 additions & 7 deletions C1_Browser-based-TF-JS/W1/assignment/C1_W1_Assignment.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
const trainingData = tf.data.csv(trainingUrl, {

// YOUR CODE HERE
columnConfigs: {
diagnosis: { isLabel: true }
}

});

Expand All @@ -21,7 +24,12 @@
// Therefore, there is no need to convert string labels into
// a one-hot encoded array of label values like we did in the
// Iris dataset example.
const convertedTrainingData = // YOUR CODE HERE
const convertedTrainingData = trainingData.map(({ xs, ys }) => {
return {
xs: Object.values(xs),
ys: Object.values(ys)
};
}).batch(32); // YOUR CODE HERE

const testingUrl = '/data/wdbc-test.csv';

Expand All @@ -32,6 +40,9 @@
const testingData = tf.data.csv(testingUrl, {

// YOUR CODE HERE
columnConfigs: {
diagnosis: { isLabel: true }
}

});

Expand All @@ -40,13 +51,18 @@
// Therefore, there is no need to convert string labels into
// a one-hot encoded array of label values like we did in the
// Iris dataset example.
const convertedTestingData = // YOUR CODE HERE
const convertedTestingData = testingData.map(({ xs, ys }) => {
return {
xs: Object.values(xs),
ys: Object.values(ys)
};
}).batch(32); // YOUR CODE HERE


// Specify the number of features in the space below.
// HINT: You can get the number of features from the number of columns
// and the number of labels in the training data.
const numOfFeatures = // YOUR CODE HERE
const numOfFeatures = 30; // YOUR CODE HERE


// In the space below create a neural network that predicts 1 if the diagnosis is malignant
Expand All @@ -60,13 +76,29 @@
const model = tf.sequential();

// YOUR CODE HERE
model.add(tf.layers.dense({
inputShape: [numOfFeatures],
units: 16,
activation: 'relu'
}));


model.add(tf.layers.dense({
units: 8,
activation: 'relu'
}));

model.add(tf.layers.dense({
units: 1,
activation: 'sigmoid'
}));

// Compile the model using the binaryCrossentropy loss,
// the rmsprop optimizer, and accuracy for your metrics.
model.compile(// YOUR CODE HERE);

model.compile( {
loss: 'binaryCrossentropy',
optimizer: 'rmsprop',
metrics: ['accuracy']
}) // YOUR CODE HERE);

await model.fitDataset(convertedTrainingData,
{epochs:100,
Expand All @@ -82,4 +114,4 @@
</script>
<body>
</body>
</html>
</html>