diff --git a/C1_Browser-based-TF-JS/W1/assignment/C1_W1_Assignment.html b/C1_Browser-based-TF-JS/W1/assignment/C1_W1_Assignment.html index 023c6143..e849674f 100755 --- a/C1_Browser-based-TF-JS/W1/assignment/C1_W1_Assignment.html +++ b/C1_Browser-based-TF-JS/W1/assignment/C1_W1_Assignment.html @@ -13,7 +13,10 @@ const trainingData = tf.data.csv(trainingUrl, { // YOUR CODE HERE - + columnConfigs: { + diagnosis: { + isLabel: true + } }); // Convert the training data into arrays in the space below. @@ -22,7 +25,9 @@ // a one-hot encoded array of label values like we did in the // Iris dataset example. const convertedTrainingData = // YOUR CODE HERE - + trainingData.map(({xs, ys}) => { + return{ xs: Object.values(xs), ys: Object.values(ys)}; + }).batch(10); const testingUrl = '/data/wdbc-test.csv'; // Take a look at the 'wdbc-test.csv' file and specify the column @@ -32,7 +37,10 @@ const testingData = tf.data.csv(testingUrl, { // YOUR CODE HERE - + columnConfigs: { + diagnosis: { + isLabel: true + } }); // Convert the testing data into arrays in the space below. @@ -41,12 +49,14 @@ // a one-hot encoded array of label values like we did in the // Iris dataset example. const convertedTestingData = // YOUR CODE HERE - + trainingData.map(({xs, ys}) => { + return{ xs: Object.values(xs), ys: Object.values(ys)}; + }).batch(10); // 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 = (await trainingData.columnNames()).length - 1; // YOUR CODE HERE // In the space below create a neural network that predicts 1 if the diagnosis is malignant @@ -61,11 +71,14 @@ // YOUR CODE HERE - + model.add(tf.layers.dense({inputShape: [numOfFeatures], activation: "relu", units: 32})) + model.add(tf.layers.dense({activation: "relu", units: 64})); + model.add(tf.layers.dense({activation: "relu", units: 32})); + model.add(tf.layers.dense({activation: "sigmoid", units: 1})); // 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: tf.train.rmsprop(0.01), metrics: ['accuracy']}) // YOUR CODE HERE); await model.fitDataset(convertedTrainingData, @@ -82,4 +95,4 @@ - \ No newline at end of file +