با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
تصور کنید درحال توسعه یک برنامه توصیه غذا هستید که در آن، کاربران غذاهای موردعلاقه خود را وارد میکنند و برنامه غذاهای مشابهی را پیشنهاد میدهد که ممکن است دوست داشته باشند. میخواهید مدل یادگیری ماشینیای را توسعه دهید که شباهت غذاها را پیشبینی کند تا برنامه شما بتواند توصیههای با کیفیت بالا ارائه دهد («چون پنکیک دوست دارید، کرپ را به شما توصیه میکنیم»).
برای آموزش مدل خود، مجموعه دادهای متشکلاز ۵٬۰۰۰ غذای پرطرفدار را گردآوری میکنید، ازجمله برشچ ،
هات داگ،
سالاد،
پیتزا،
و شاورما.
شکل ۱. نمونه غذاهای موجود در مجموعه داده غذا.
ویژگی meal ایجاد میکنید که شامل نمایش کدبندیشده وان هات از هریک از غذاهای موجود در مجموعه داده است.
کدبندی به فرایند انتخاب نمایش عددی اولیه دادهها برای آموزش مدل اشاره دارد.
شکل ۲. کدبندیهای وان هات برشچ، هات داگ، و شاورما.
هر بردار کدبندی وان هات دارای طول ۵٬۰۰۰ است (یک ورودی برای هر گزینه منو در مجموعه داده). سهنقطه در نمودار نشاندهنده ۴٬۹۹۵ ورودی نمایش دادهنشده است.
مشکلات مربوط به ارائه دادههای پراکنده
با بررسی کردن این کدبندیهای وان هات، چندین مشکل را در این نمایش دادهها مشاهده میکنید.
تعداد وزنها. بردارهای ورودی بزرگ بهمعنای تعداد زیادی
وزن
برای شبکه عصبی است.
با M ورودی در کدبندی وان هات و N گره در اولین لایه شبکه پساز ورودی، مدل باید MxN وزن را برای آن لایه آموزش دهد.
تعداد نقاط داده. هرچه مدل شما وزنهای بیشتری داشته باشد، برای آموزش مؤثر به دادههای بیشتری نیاز خواهید داشت.
میزان محاسبات. هرچه وزنها بیشتر باشند، مقدار محاسبات لازم برای آموزش و استفاده از مدل افزایش مییابد. مدل به راحتی میتواند از تواناییهای سختافزاری فراتر برود.
مقدار حافظه. هرچه مدل شما وزنهای بیشتری داشته باشد، شتابدهندههایی که آن را آموزش میدهند و اجرا میکنند به حافظه بیشتری نیاز خواهند داشت. گسترش این فرایند بهصورت کارآمد بسیار دشوار است.
دشواری پشتیبانی از
یادگیری ماشین دروندستگاهی (ODML).
اگر میخواهید مدل یادگیری ماشینتان را روی دستگاههای محلی اجرا کنید (بهجای پیادهسازی آن در سرور)، باید روی کوچکتر کردن مدل تمرکز کنید و تعداد وزنها را کاهش دهید.
در این واحد، با نحوه ایجاد کردن جاسازی، نمایش کمبُعدتر دادههای پراکنده که این مشکلات را برطرف میکند، آشنا میشوید.
تاریخ آخرین بهروزرسانی 2025-05-20 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-05-20 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eThis module explains how to create embeddings, which are lower-dimensional representations of sparse data that address the problems of large input vectors and lack of meaningful relations between vectors in one-hot encoding.\u003c/p\u003e\n"],["\u003cp\u003eOne-hot encoding creates large input vectors, leading to a huge number of weights in a neural network, requiring more data, computation, and memory.\u003c/p\u003e\n"],["\u003cp\u003eOne-hot encoding vectors lack meaningful relationships, failing to capture semantic similarities between items, like the example of hot dogs and shawarmas being more similar than hot dogs and salads.\u003c/p\u003e\n"],["\u003cp\u003eEmbeddings offer a solution by providing dense vector representations that capture semantic relationships and reduce the dimensionality of data, improving efficiency and performance in machine learning models.\u003c/p\u003e\n"],["\u003cp\u003eThis module assumes familiarity with introductory machine learning concepts like linear regression, categorical data, and neural networks.\u003c/p\u003e\n"]]],[],null,["# Embeddings\n\n| **Estimated module length:** 45 minutes\n| **Learning objectives**\n|\n| - Visualize vector representations of word embeddings, such as [word2vec](https://wikipedia.org/wiki/Word2vec).\n| - Distinguish encoding from embedding.\n| - Describe contextual embedding.\n| **Prerequisites:**\n|\n| This module assumes you are familiar with the concepts covered in the\n| following modules:\n|\n| - [Introduction to Machine Learning](/machine-learning/intro-to-ml)\n| - [Linear regression](/machine-learning/crash-course/linear-regression)\n| - [Working with categorical data](/machine-learning/crash-course/categorical-data)\n| - [Neural networks](/machine-learning/crash-course/neural-networks)\n\nImagine you're developing a food-recommendation application, where\nusers input their favorite meals, and the app suggests similar meals\nthat they might like. You want to develop a machine learning (ML) model\nthat can predict food similarity, so your app can make high quality\nrecommendations (\"Since you like pancakes, we recommend crepes\").\n\nTo train your model, you curate a dataset of 5,000 popular\nmeal items, including ,\n,\n,\n,\nand .\n**Figure 1.** Sampling of meal items included in the food dataset.\n\nYou create a `meal` feature that contains a\n[**one-hot encoded**](/machine-learning/glossary#one-hot-encoding)\nrepresentation of each of the meal items in the dataset.\n[**Encoding**](/machine-learning/glossary#encoder) refers to the process of\nchoosing an initial numerical representation of data to train the model on.\n**Figure 2.** One-hot encodings of borscht, hot dog, and shawarma. Each one-hot encoding vector has a length of 5,000 (one entry for each menu item in the dataset). The ellipsis in the diagram represents the 4,995 entries not shown.\n\nPitfalls of sparse data representations\n---------------------------------------\n\nReviewing these one-hot encodings, you notice several problems with this\nrepresentation of the data.\n\n- **Number of weights.** Large input vectors mean a huge number of [**weights**](/machine-learning/glossary#weight) for a [**neural network**](/machine-learning/glossary#neural-network). With M entries in your one-hot encoding, and N nodes in the first layer of the network after the input, the model has to train MxN weights for that layer.\n- **Number of datapoints.** The more weights in your model, the more data you need to train effectively.\n- **Amount of computation.** The more weights, the more computation required to train and use the model. It's easy to exceed the capabilities of your hardware.\n- **Amount of memory.** The more weights in your model, the more memory that is needed on the accelerators that train and serve it. Scaling this up efficiently is very difficult.\n- **Difficulty of supporting on-device machine learning (ODML).** If you're hoping to run your ML model on local devices (as opposed to serving them), you'll need to be focused on making your model smaller, and will want to decrease the number of weights.\n\nIn this module, you'll learn how to create **embeddings**, lower-dimensional\nrepresentations of sparse data, that address these issues.\n| **Key terms:**\n|\n| - [One-hot encoding](/machine-learning/glossary#one-hot-encoding)\n| - [Neural network](/machine-learning/glossary#neural-network)\n- [Weight](/machine-learning/glossary#weight) \n[Help Center](https://support.google.com/machinelearningeducation)"]]