උෂ්ණත්වයසමඟ භාෂා ආකෘති වලින් නියැදීම

මෙන්නඅපි පහත සඳහන් සම්භාවිතා ව්යාප්තියෙන් නියැදිය, වාග් මාලාව කොහෙද , බෙදා හැරීමේ පිවිසුම් සහ T යනු උෂ්ණත්වය:

සාමාන්ය අහඹු නියැදීම් වේ.

මෙන්නමෙම නියැදි ශිල්පීය ක්රම භාවිතා කරන අත්හදා බැලීමක් .

19import torch
20from torch.distributions import Categorical
21
22from labml_nn.sampling import Sampler

උෂ්ණත්වයසමඟ නියැදිකරු

25class TemperatureSampler(Sampler):
  • temperature සමඟ නියැදිය යුතු උෂ්ණත්වය වේ
29    def __init__(self, temperature: float = 1.0):
33        self.temperature = temperature

පිවිසුම්වලින් නියැදිය

35    def __call__(self, logits: torch.Tensor):

උෂ්ණත්වගැලපුම් පිවිසුම් සමඟ වර්ගීකරණ බෙදාහැරීමක් සාදන්න

41        dist = Categorical(logits=logits / self.temperature)

නියැදිය

44        return dist.sample()