|
9 | 9 | "\n", |
10 | 10 | "Reference: \n", |
11 | 11 | "https://huggingface.co/docs/transformers/training#train-a-tensorflow-model-with-keras \n", |
12 | | - "https://huggingface.co/learn/nlp-course/chapter3/3?fw=tf\n", |
13 | 12 | "\n", |
14 | 13 | "\n", |
15 | | - "https://learnopencv.com/fine-tuning-bert/ \n", |
16 | | - "\n", |
17 | | - "\n", |
18 | | - "\n", |
19 | | - "\n", |
20 | | - "https://www.youtube.com/watch?v=RgpANRh44ao \n", |
21 | | - "Notebook Link: https://www.kaggle.com/code/preatcher/emotion-detection-by-using-bert\n", |
22 | | - "Github App Link: https://github.com/Abhishekjl/Sentiment-analyis-BERT-Trained-\n", |
23 | | - "\n", |
24 | | - "There are significant benefits to using a pretrained model. It reduces computation costs, your carbon footprint, and allows you to use state-of-the-art models without having to train one from scratch. 🤗 Transformers provides access to thousands of pretrained models for a wide range of tasks. When you use a pretrained model, you train it on a dataset specific to your task. This is known as fine-tuning, an incredibly powerful training technique. \n", |
25 | | - "\n", |
26 | 14 | "**Steps**\n", |
27 | 15 | "1. Load the data\n", |
28 | 16 | "2. Apply tokenization to the dataset\n", |
|
31 | 19 | }, |
32 | 20 | { |
33 | 21 | "cell_type": "code", |
34 | | - "execution_count": 2, |
| 22 | + "execution_count": 1, |
35 | 23 | "id": "0c5291d1-83ad-4e36-a3b9-0aeb161118fc", |
36 | 24 | "metadata": {}, |
37 | 25 | "outputs": [ |
|
51 | 39 | }, |
52 | 40 | { |
53 | 41 | "cell_type": "code", |
54 | | - "execution_count": 1, |
| 42 | + "execution_count": 2, |
55 | 43 | "id": "aba7b9e3-d558-45a1-9b03-ef697e243cba", |
56 | 44 | "metadata": {}, |
57 | 45 | "outputs": [ |
|
61 | 49 | "text": [ |
62 | 50 | "2.16.1\n" |
63 | 51 | ] |
64 | | - }, |
65 | | - { |
66 | | - "ename": "AttributeError", |
67 | | - "evalue": "module 'keras._tf_keras.keras' has no attribute '__version__'", |
68 | | - "output_type": "error", |
69 | | - "traceback": [ |
70 | | - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", |
71 | | - "\u001b[1;31mAttributeError\u001b[0m Traceback (most recent call last)", |
72 | | - "Cell \u001b[1;32mIn[1], line 8\u001b[0m\n\u001b[0;32m 4\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mtensorflow\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m keras\n\u001b[0;32m 6\u001b[0m \u001b[38;5;28mprint\u001b[39m(tf\u001b[38;5;241m.\u001b[39m__version__)\n\u001b[1;32m----> 8\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[43mkeras\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m__version__\u001b[49m)\n", |
73 | | - "File \u001b[1;32m~\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\tensorflow\\python\\util\\lazy_loader.py:211\u001b[0m, in \u001b[0;36mKerasLazyLoader.__getattr__\u001b[1;34m(self, item)\u001b[0m\n\u001b[0;32m 207\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mAttributeError\u001b[39;00m(\n\u001b[0;32m 208\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m`\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mitem\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m` is not available with Keras 3.\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 209\u001b[0m )\n\u001b[0;32m 210\u001b[0m module \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_load()\n\u001b[1;32m--> 211\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mgetattr\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mmodule\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mitem\u001b[49m\u001b[43m)\u001b[49m\n", |
74 | | - "\u001b[1;31mAttributeError\u001b[0m: module 'keras._tf_keras.keras' has no attribute '__version__'" |
75 | | - ] |
76 | 52 | } |
77 | 53 | ], |
78 | 54 | "source": [ |
79 | | - "# TensorFlow and tf.keras\n", |
80 | | - "\n", |
81 | 55 | "import tensorflow as tf\n", |
82 | | - "from tensorflow import keras\n", |
83 | | - "\n", |
84 | | - "print(tf.__version__)\n", |
85 | 56 | "\n", |
86 | | - "print(keras.__version__)" |
| 57 | + "print(tf.__version__)" |
87 | 58 | ] |
88 | 59 | }, |
89 | 60 | { |
90 | 61 | "cell_type": "code", |
91 | | - "execution_count": 1, |
| 62 | + "execution_count": 3, |
92 | 63 | "id": "a9c3a86f-dd64-48a6-b6dd-6013d2ae9412", |
93 | 64 | "metadata": {}, |
94 | 65 | "outputs": [], |
|
98 | 69 | }, |
99 | 70 | { |
100 | 71 | "cell_type": "code", |
101 | | - "execution_count": 2, |
| 72 | + "execution_count": 4, |
102 | 73 | "id": "a8733911-db8b-40bf-82e3-2a052515d1f5", |
103 | 74 | "metadata": {}, |
104 | 75 | "outputs": [ |
|
198 | 169 | "4 NEW YORK -- Indecision marked the dollar's ton... " |
199 | 170 | ] |
200 | 171 | }, |
201 | | - "execution_count": 2, |
| 172 | + "execution_count": 4, |
202 | 173 | "metadata": {}, |
203 | 174 | "output_type": "execute_result" |
204 | 175 | } |
|
211 | 182 | }, |
212 | 183 | { |
213 | 184 | "cell_type": "code", |
214 | | - "execution_count": 3, |
| 185 | + "execution_count": 5, |
215 | 186 | "id": "67609b5a-6160-4c9b-9ff4-3e2306372e19", |
216 | 187 | "metadata": {}, |
217 | 188 | "outputs": [ |
|
221 | 192 | "(8000, 5)" |
222 | 193 | ] |
223 | 194 | }, |
224 | | - "execution_count": 3, |
| 195 | + "execution_count": 5, |
225 | 196 | "metadata": {}, |
226 | 197 | "output_type": "execute_result" |
227 | 198 | } |
|
232 | 203 | }, |
233 | 204 | { |
234 | 205 | "cell_type": "code", |
235 | | - "execution_count": 4, |
| 206 | + "execution_count": 6, |
236 | 207 | "id": "4c109e2e-d967-43f7-812e-18acbe145acb", |
237 | 208 | "metadata": {}, |
238 | 209 | "outputs": [ |
|
246 | 217 | "Name: proportion, dtype: float64" |
247 | 218 | ] |
248 | 219 | }, |
249 | | - "execution_count": 4, |
| 220 | + "execution_count": 6, |
250 | 221 | "metadata": {}, |
251 | 222 | "output_type": "execute_result" |
252 | 223 | } |
|
257 | 228 | }, |
258 | 229 | { |
259 | 230 | "cell_type": "code", |
260 | | - "execution_count": 5, |
| 231 | + "execution_count": 7, |
261 | 232 | "id": "f924c3d2-75bd-44d4-825f-8a37d1108f84", |
262 | 233 | "metadata": {}, |
263 | 234 | "outputs": [ |
|
270 | 241 | "Name: proportion, dtype: float64" |
271 | 242 | ] |
272 | 243 | }, |
273 | | - "execution_count": 5, |
| 244 | + "execution_count": 7, |
274 | 245 | "metadata": {}, |
275 | 246 | "output_type": "execute_result" |
276 | 247 | } |
|
285 | 256 | }, |
286 | 257 | { |
287 | 258 | "cell_type": "code", |
288 | | - "execution_count": 9, |
| 259 | + "execution_count": 8, |
289 | 260 | "id": "efa3c67b-8201-44eb-8506-e094e7dc07db", |
290 | 261 | "metadata": {}, |
291 | 262 | "outputs": [], |
|
298 | 269 | }, |
299 | 270 | { |
300 | 271 | "cell_type": "code", |
301 | | - "execution_count": 10, |
| 272 | + "execution_count": 9, |
302 | 273 | "id": "ab2914ad-44ca-47cb-98ee-4227b6a31097", |
303 | 274 | "metadata": {}, |
304 | 275 | "outputs": [], |
|
311 | 282 | }, |
312 | 283 | { |
313 | 284 | "cell_type": "code", |
314 | | - "execution_count": 12, |
| 285 | + "execution_count": 10, |
315 | 286 | "id": "d9e3a194-b9c9-4041-90f9-cfd43fff9f4b", |
316 | 287 | "metadata": {}, |
317 | 288 | "outputs": [ |
|
337 | 308 | }, |
338 | 309 | { |
339 | 310 | "cell_type": "code", |
340 | | - "execution_count": 13, |
| 311 | + "execution_count": 11, |
341 | 312 | "id": "a9272140-12e4-4c8a-9307-cbd135bfc15b", |
342 | 313 | "metadata": {}, |
343 | | - "outputs": [ |
344 | | - { |
345 | | - "data": { |
346 | | - "application/vnd.jupyter.widget-view+json": { |
347 | | - "model_id": "e3fb92a246514e888ec7379e1da18a62", |
348 | | - "version_major": 2, |
349 | | - "version_minor": 0 |
350 | | - }, |
351 | | - "text/plain": [ |
352 | | - "tokenizer_config.json: 0%| | 0.00/28.0 [00:00<?, ?B/s]" |
353 | | - ] |
354 | | - }, |
355 | | - "metadata": {}, |
356 | | - "output_type": "display_data" |
357 | | - }, |
358 | | - { |
359 | | - "name": "stderr", |
360 | | - "output_type": "stream", |
361 | | - "text": [ |
362 | | - "C:\\Users\\DELL\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\huggingface_hub\\file_download.py:149: UserWarning: `huggingface_hub` cache-system uses symlinks by default to efficiently store duplicated files but your machine does not support them in C:\\Users\\DELL\\.cache\\huggingface\\hub\\models--distilbert-base-uncased. Caching files will still work but in a degraded version that might require more space on your disk. This warning can be disabled by setting the `HF_HUB_DISABLE_SYMLINKS_WARNING` environment variable. For more details, see https://huggingface.co/docs/huggingface_hub/how-to-cache#limitations.\n", |
363 | | - "To support symlinks on Windows, you either need to activate Developer Mode or to run Python as an administrator. In order to see activate developer mode, see this article: https://docs.microsoft.com/en-us/windows/apps/get-started/enable-your-device-for-development\n", |
364 | | - " warnings.warn(message)\n" |
365 | | - ] |
366 | | - }, |
367 | | - { |
368 | | - "data": { |
369 | | - "application/vnd.jupyter.widget-view+json": { |
370 | | - "model_id": "70dfac598d3f48e0a494c914c6150693", |
371 | | - "version_major": 2, |
372 | | - "version_minor": 0 |
373 | | - }, |
374 | | - "text/plain": [ |
375 | | - "config.json: 0%| | 0.00/483 [00:00<?, ?B/s]" |
376 | | - ] |
377 | | - }, |
378 | | - "metadata": {}, |
379 | | - "output_type": "display_data" |
380 | | - }, |
381 | | - { |
382 | | - "data": { |
383 | | - "application/vnd.jupyter.widget-view+json": { |
384 | | - "model_id": "b861ceae22df4de399324abee8cee86a", |
385 | | - "version_major": 2, |
386 | | - "version_minor": 0 |
387 | | - }, |
388 | | - "text/plain": [ |
389 | | - "vocab.txt: 0%| | 0.00/232k [00:00<?, ?B/s]" |
390 | | - ] |
391 | | - }, |
392 | | - "metadata": {}, |
393 | | - "output_type": "display_data" |
394 | | - }, |
395 | | - { |
396 | | - "data": { |
397 | | - "application/vnd.jupyter.widget-view+json": { |
398 | | - "model_id": "0e910174400d4409a950e6069f2f724b", |
399 | | - "version_major": 2, |
400 | | - "version_minor": 0 |
401 | | - }, |
402 | | - "text/plain": [ |
403 | | - "tokenizer.json: 0%| | 0.00/466k [00:00<?, ?B/s]" |
404 | | - ] |
405 | | - }, |
406 | | - "metadata": {}, |
407 | | - "output_type": "display_data" |
408 | | - } |
409 | | - ], |
| 314 | + "outputs": [], |
410 | 315 | "source": [ |
411 | 316 | "from transformers import AutoTokenizer\n", |
412 | 317 | "\n", |
|
0 commit comments