arirajuns commited on
Commit
e3a3570
·
verified ·
1 Parent(s): 2b47e21

Add 3 files

Browse files
Files changed (3) hide show
  1. README.md +7 -5
  2. index.html +223 -19
  3. prompts.txt +1 -0
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: T1
3
- emoji: 🏃
4
- colorFrom: red
5
- colorTo: yellow
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: t1
3
+ emoji: 🐳
4
+ colorFrom: purple
5
+ colorTo: gray
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite
10
  ---
11
 
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
index.html CHANGED
@@ -1,19 +1,223 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Tensor Calculations Showcase</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
9
+ <style>
10
+ .code-block {
11
+ background-color: #1e293b;
12
+ color: #f8fafc;
13
+ border-radius: 0.5rem;
14
+ padding: 1rem;
15
+ font-family: 'Courier New', monospace;
16
+ position: relative;
17
+ }
18
+ .copy-btn {
19
+ position: absolute;
20
+ top: 0.5rem;
21
+ right: 0.5rem;
22
+ background-color: #334155;
23
+ color: white;
24
+ border: none;
25
+ border-radius: 0.25rem;
26
+ padding: 0.25rem 0.5rem;
27
+ cursor: pointer;
28
+ font-size: 0.75rem;
29
+ }
30
+ .copy-btn:hover {
31
+ background-color: #475569;
32
+ }
33
+ .tensor-visualization {
34
+ display: flex;
35
+ flex-direction: column;
36
+ align-items: center;
37
+ margin: 1rem 0;
38
+ }
39
+ .tensor-cell {
40
+ border: 1px solid #cbd5e1;
41
+ padding: 0.5rem;
42
+ text-align: center;
43
+ background-color: #f8fafc;
44
+ }
45
+ .tensor-row {
46
+ display: flex;
47
+ margin-bottom: 0.25rem;
48
+ }
49
+ .tab-content {
50
+ display: none;
51
+ }
52
+ .tab-content.active {
53
+ display: block;
54
+ }
55
+ .tab-button {
56
+ transition: all 0.3s ease;
57
+ }
58
+ .tab-button.active {
59
+ background-color: #3b82f6;
60
+ color: white;
61
+ }
62
+ </style>
63
+ </head>
64
+ <body class="bg-gray-50 min-h-screen">
65
+ <div class="container mx-auto px-4 py-8 max-w-6xl">
66
+ <header class="text-center mb-12">
67
+ <h1 class="text-4xl font-bold text-blue-600 mb-2">
68
+ <i class="fas fa-calculator mr-2"></i>Tensor Calculations in Python
69
+ </h1>
70
+ <p class="text-gray-600 text-lg">
71
+ Interactive showcase of tensor operations with NumPy and PyTorch
72
+ </p>
73
+ </header>
74
+
75
+ <div class="bg-white rounded-xl shadow-md overflow-hidden mb-8">
76
+ <div class="p-6">
77
+ <h2 class="text-2xl font-semibold text-gray-800 mb-4">Introduction to Tensors</h2>
78
+ <p class="text-gray-600 mb-4">
79
+ Tensors are multi-dimensional arrays that generalize scalars, vectors, and matrices to higher dimensions.
80
+ They are fundamental in machine learning and deep learning frameworks.
81
+ </p>
82
+
83
+ <div class="flex flex-wrap gap-2 mb-6">
84
+ <button class="tab-button active px-4 py-2 rounded-lg bg-blue-100 text-blue-700" onclick="openTab(event, 'numpy-tab')">
85
+ <i class="fas fa-table mr-2"></i>NumPy
86
+ </button>
87
+ <button class="tab-button px-4 py-2 rounded-lg bg-gray-100 text-gray-700" onclick="openTab(event, 'pytorch-tab')">
88
+ <i class="fas fa-brain mr-2"></i>PyTorch
89
+ </button>
90
+ <button class="tab-button px-4 py-2 rounded-lg bg-gray-100 text-gray-700" onclick="openTab(event, 'visualization-tab')">
91
+ <i class="fas fa-eye mr-2"></i>Visualization
92
+ </button>
93
+ </div>
94
+
95
+ <div id="numpy-tab" class="tab-content active">
96
+ <h3 class="text-xl font-semibold text-gray-800 mb-3">NumPy Tensors</h3>
97
+ <p class="text-gray-600 mb-4">
98
+ NumPy provides powerful N-dimensional array objects that we can use as tensors.
99
+ Here are some basic operations:
100
+ </p>
101
+
102
+ <div class="grid md:grid-cols-2 gap-6">
103
+ <div>
104
+ <h4 class="font-medium text-gray-700 mb-2">Creating Tensors</h4>
105
+ <div class="code-block mb-4">
106
+ <button class="copy-btn" onclick="copyCode(this)">Copy</button>
107
+ <pre>import numpy as np
108
+
109
+ # Scalar (0D tensor)
110
+ scalar = np.array(5)
111
+
112
+ # Vector (1D tensor)
113
+ vector = np.array([1, 2, 3])
114
+
115
+ # Matrix (2D tensor)
116
+ matrix = np.array([[1, 2], [3, 4]])
117
+
118
+ # 3D tensor
119
+ tensor_3d = np.array([[[1, 2], [3, 4]],
120
+ [[5, 6], [7, 8]]])</pre>
121
+ </div>
122
+ </div>
123
+
124
+ <div>
125
+ <h4 class="font-medium text-gray-700 mb-2">Basic Operations</h4>
126
+ <div class="code-block">
127
+ <button class="copy-btn" onclick="copyCode(this)">Copy</button>
128
+ <pre># Element-wise addition
129
+ a = np.array([1, 2, 3])
130
+ b = np.array([4, 5, 6])
131
+ result = a + b # [5, 7, 9]
132
+
133
+ # Matrix multiplication
134
+ mat_a = np.array([[1, 2], [3, 4]])
135
+ mat_b = np.array([[5, 6], [7, 8]])
136
+ result = np.dot(mat_a, mat_b)
137
+
138
+ # Reshaping
139
+ tensor = np.arange(8) # [0,1,2,3,4,5,6,7]
140
+ reshaped = tensor.reshape((2, 4))</pre>
141
+ </div>
142
+ </div>
143
+ </div>
144
+ </div>
145
+
146
+ <div id="pytorch-tab" class="tab-content">
147
+ <h3 class="text-xl font-semibold text-gray-800 mb-3">PyTorch Tensors</h3>
148
+ <p class="text-gray-600 mb-4">
149
+ PyTorch tensors are similar to NumPy arrays but with GPU acceleration support and automatic differentiation capabilities.
150
+ </p>
151
+
152
+ <div class="grid md:grid-cols-2 gap-6">
153
+ <div>
154
+ <h4 class="font-medium text-gray-700 mb-2">Creating PyTorch Tensors</h4>
155
+ <div class="code-block mb-4">
156
+ <button class="copy-btn" onclick="copyCode(this)">Copy</button>
157
+ <pre>import torch
158
+
159
+ # Create tensors
160
+ scalar = torch.tensor(5)
161
+ vector = torch.tensor([1., 2., 3.])
162
+ matrix = torch.tensor([[1, 2], [3, 4]])
163
+
164
+ # GPU tensor (if available)
165
+ if torch.cuda.is_available():
166
+ gpu_tensor = torch.tensor([1, 2, 3], device='cuda')
167
+
168
+ # With gradient tracking
169
+ x = torch.tensor(2., requires_grad=True)</pre>
170
+ </div>
171
+ </div>
172
+
173
+ <div>
174
+ <h4 class="font-medium text-gray-700 mb-2">Autograd Example</h4>
175
+ <div class="code-block">
176
+ <button class="copy-btn" onclick="copyCode(this)">Copy</button>
177
+ <pre># Automatic differentiation example
178
+ x = torch.tensor(2., requires_grad=True)
179
+ y = x**2 + 3*x + 1
180
+
181
+ # Compute gradient
182
+ y.backward()
183
+
184
+ print(x.grad) # dy/dx = 2x + 3 → 7</pre>
185
+ </div>
186
+ <button onclick="runAutogradDemo()" class="mt-4 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition">
187
+ <i class="fas fa-play mr-2"></i>Run Autograd Demo
188
+ </button>
189
+ <div id="autograd-result" class="mt-2 p-3 bg-gray-100 rounded hidden"></div>
190
+ </div>
191
+ </div>
192
+ </div>
193
+
194
+ <div id="visualization-tab" class="tab-content">
195
+ <h3 class="text-xl font-semibold text-gray-800 mb-3">Tensor Visualization</h3>
196
+ <p class="text-gray-600 mb-4">
197
+ Understanding tensor shapes and dimensions is crucial. Here's how different rank tensors look:
198
+ </p>
199
+
200
+ <div class="grid md:grid-cols-3 gap-4">
201
+ <div class="border rounded-lg p-4">
202
+ <h4 class="font-medium text-center mb-3">Scalar (0D)</h4>
203
+ <div class="tensor-visualization">
204
+ <div class="tensor-cell" style="width: 60px;">5</div>
205
+ </div>
206
+ <p class="text-sm text-gray-500 mt-2">Shape: ()</p>
207
+ </div>
208
+
209
+ <div class="border rounded-lg p-4">
210
+ <h4 class="font-medium text-center mb-3">Vector (1D)</h4>
211
+ <div class="tensor-visualization">
212
+ <div class="tensor-row">
213
+ <div class="tensor-cell">1</div>
214
+ <div class="tensor-cell">2</div>
215
+ <div class="tensor-cell">3</div>
216
+ </div>
217
+ </div>
218
+ <p class="text-sm text-gray-500 mt-2">Shape: (3,)</p>
219
+ </div>
220
+
221
+ <div class="border rounded-lg p-4">
222
+ <h4 class="font-medium text-center mb-
223
+ </html>
prompts.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ Create an python project to show case various tensor calculations, with simple examples and explanation.