From cc47b2c61e40f5e61a1983a283c1df33cafe1685 Mon Sep 17 00:00:00 2001 From: Duvandal <71871585+Duvandal@users.noreply.github.com> Date: Mon, 10 May 2021 10:26:57 +0700 Subject: [PATCH] Update wdbc_exercise.html --- .../Week 1/Exercise/wdbc_exercise.html | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/TensorFlow Deployment/Course 1 - TensorFlow-JS/Week 1/Exercise/wdbc_exercise.html b/TensorFlow Deployment/Course 1 - TensorFlow-JS/Week 1/Exercise/wdbc_exercise.html index 44762613..5a6154c6 100755 --- a/TensorFlow Deployment/Course 1 - TensorFlow-JS/Week 1/Exercise/wdbc_exercise.html +++ b/TensorFlow Deployment/Course 1 - TensorFlow-JS/Week 1/Exercise/wdbc_exercise.html @@ -13,7 +13,12 @@ const trainingData = tf.data.csv(trainingUrl, { // YOUR CODE HERE - + columnConfigs:{ + diagnosis:{ + isLabel: true + } + } + }); // Convert the training data into arrays in the space below. @@ -21,7 +26,9 @@ // 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(10); const testingUrl = 'wdbc-test.csv'; @@ -32,6 +39,11 @@ const testingData = tf.data.csv(testingUrl, { // YOUR CODE HERE + columnConfigs:{ + diagnosis:{ + isLabel: true + } + } }); @@ -40,13 +52,15 @@ // 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 = 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; // In the space below create a neural network that predicts 1 if the diagnosis is malignant @@ -61,11 +75,13 @@ // YOUR CODE HERE - + model.add(tf.layers.dense({inputShape: [numOfFeatures],activation:"sigmoid",units:31 })) + model.add(tf.layers.dense({activation:"sigmoid",units:15 })) + 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.05)}); await model.fitDataset(convertedTrainingData, @@ -82,4 +98,4 @@ - \ No newline at end of file +