Skip to content

Commit eaeb06b

Browse files
committed
pushtaev: part 1 solution
1 parent c9404fc commit eaeb06b

File tree

1 file changed

+55
-15
lines changed

1 file changed

+55
-15
lines changed

intro-to-pytorch/Part 1 - Tensors in PyTorch (Exercises).ipynb

+55-15
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
},
6161
{
6262
"cell_type": "code",
63-
"execution_count": null,
63+
"execution_count": 4,
6464
"metadata": {},
6565
"outputs": [],
6666
"source": [
@@ -70,7 +70,7 @@
7070
},
7171
{
7272
"cell_type": "code",
73-
"execution_count": null,
73+
"execution_count": 5,
7474
"metadata": {},
7575
"outputs": [],
7676
"source": [
@@ -86,7 +86,7 @@
8686
},
8787
{
8888
"cell_type": "code",
89-
"execution_count": null,
89+
"execution_count": 7,
9090
"metadata": {},
9191
"outputs": [],
9292
"source": [
@@ -119,11 +119,24 @@
119119
},
120120
{
121121
"cell_type": "code",
122-
"execution_count": null,
122+
"execution_count": 16,
123123
"metadata": {},
124-
"outputs": [],
124+
"outputs": [
125+
{
126+
"data": {
127+
"text/plain": [
128+
"tensor([[0.1595]])"
129+
]
130+
},
131+
"execution_count": 16,
132+
"metadata": {},
133+
"output_type": "execute_result"
134+
}
135+
],
125136
"source": [
126-
"## Calculate the output of this network using the weights and bias tensors"
137+
"## Calculate the output of this network using the weights and bias tensors\n",
138+
"\n",
139+
"activation((features*weights).sum() + bias)"
127140
]
128141
},
129142
{
@@ -162,11 +175,24 @@
162175
},
163176
{
164177
"cell_type": "code",
165-
"execution_count": null,
178+
"execution_count": 31,
166179
"metadata": {},
167-
"outputs": [],
180+
"outputs": [
181+
{
182+
"data": {
183+
"text/plain": [
184+
"tensor([[0.1595]])"
185+
]
186+
},
187+
"execution_count": 31,
188+
"metadata": {},
189+
"output_type": "execute_result"
190+
}
191+
],
168192
"source": [
169-
"## Calculate the output of this network using matrix multiplication"
193+
"## Calculate the output of this network using matrix multiplication\n",
194+
"\n",
195+
"activation(torch.mm(features, weights.view(5,1)) + bias)"
170196
]
171197
},
172198
{
@@ -204,7 +230,7 @@
204230
},
205231
{
206232
"cell_type": "code",
207-
"execution_count": null,
233+
"execution_count": 46,
208234
"metadata": {},
209235
"outputs": [],
210236
"source": [
@@ -238,11 +264,25 @@
238264
},
239265
{
240266
"cell_type": "code",
241-
"execution_count": null,
267+
"execution_count": 47,
242268
"metadata": {},
243-
"outputs": [],
269+
"outputs": [
270+
{
271+
"data": {
272+
"text/plain": [
273+
"tensor([[0.3171]])"
274+
]
275+
},
276+
"execution_count": 47,
277+
"metadata": {},
278+
"output_type": "execute_result"
279+
}
280+
],
244281
"source": [
245-
"## Your solution here"
282+
"## Your solution here\n",
283+
"\n",
284+
"H = activation(torch.mm(features, W1) + B1)\n",
285+
"activation(torch.mm(H, W2) + B2)"
246286
]
247287
},
248288
{
@@ -325,7 +365,7 @@
325365
],
326366
"metadata": {
327367
"kernelspec": {
328-
"display_name": "Python 3",
368+
"display_name": "Python 3 (ipykernel)",
329369
"language": "python",
330370
"name": "python3"
331371
},
@@ -339,7 +379,7 @@
339379
"name": "python",
340380
"nbconvert_exporter": "python",
341381
"pygments_lexer": "ipython3",
342-
"version": "3.6.6"
382+
"version": "3.8.10"
343383
}
344384
},
345385
"nbformat": 4,

0 commit comments

Comments
 (0)