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

Assignment 1 #18

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 41 additions & 14 deletions 01_materials/labs/lab_1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,15 @@
"Because of this, we need to convert our labels from an integer value into a one-hot encoded vector. This means that each label will be represented as a vector of length 10, with a 1 in the position corresponding to the class, and 0s everywhere else. For example, the label 9 would be represented as `[0, 0, 0, 0, 0, 0, 0, 0, 0, 1]`. This is a common way of representing categorical data in machine learning. By doing this, we ensure that our model is taught the correct relationship between the classes."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"pip install tensorflow"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -482,7 +491,22 @@
"metadata": {},
"outputs": [],
"source": [
"# Your code here - copy the relevant parts from the previous section and add more cells as needed"
"from tensorflow.keras import optimizers\n",
"model = Sequential()\n",
"\n",
"# Input layer\n",
"model.add(Dense(64, activation='relu', input_shape=(64,))) # 64 neurons, ReLU activation, input shape of 64\n",
"\n",
"# Hidden layer\n",
"model.add(Dense(64, activation='relu')) # 64 neurons, ReLU activation\n",
"\n",
"# Output layer\n",
"model.add(Dense(10, activation='softmax')) # 10 neurons, softmax activation\n",
"\n",
"model.summary()\n",
"\n",
"model.compile(optimizer=optimizers.SGD(learning_rate=0.001), loss='categorical_crossentropy', metrics=['accuracy'])\n",
"history = model.fit(X_train, y_train, epochs=15, batch_size=32)"
]
},
{
Expand All @@ -504,7 +528,22 @@
"metadata": {},
"outputs": [],
"source": [
"# Your code here"
"# Your code hefrom tensorflow.keras import optimizers\n",
"model = Sequential()\n",
"\n",
"# Input layer\n",
"model.add(Dense(64, activation='relu', input_shape=(64,))) # 64 neurons, ReLU activation, input shape of 64\n",
"\n",
"# Hidden layer\n",
"model.add(Dense(64, activation='relu')) # 64 neurons, ReLU activation\n",
"\n",
"# Output layer\n",
"model.add(Dense(10, activation='softmax')) # 10 neurons, softmax activation\n",
"\n",
"model.summary()\n",
"\n",
"model.compile(optimizer=optimizers.SGD(learning_rate=0.01, momentum=0.9),loss='categorical_crossentropy', metrics=['accuracy'])\n",
"history = model.fit(X_train, y_train, epochs=15, batch_size=32)"
]
},
{
Expand Down Expand Up @@ -798,18 +837,6 @@
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.8"
},
"mimetype": "text/x-python",
"name": "python",
"npconvert_exporter": "python",
Expand Down
Loading
Loading