/
vuron
/
adept
Обзор
Документация
Войти
/
vuron
/
adept
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
python/torch_refs/torch_activations.py
32 строки
485 B
kolkir
Refactor python folder structure
01 мар 2025, 22:16
01 мар 2025, 22:16
ef25f05
Код
Авторство
О чём код?
import torch import torch.nn.functional as F def test_activation(act_func): x = torch.tensor( [[[[0, 2, -3], [4, -5, 0], [-7, 0, 9]]]], dtype=torch.float32, requires_grad=True, ) y = act_func(x) print(y.shape) print(y) y.mean().backward() print(x.grad) print("ReLU") test_activation(F.relu) print("LeakyReLU") test_activation(F.leaky_relu) print("Sigmoid") test_activation(F.sigmoid) print("SiLU") test_activation(F.silu)