Download pool/shard011/Python/0096561_v_function.py from Variable-role/sajaniemi_variable_dataset_large: direct link, hf CLI and curl.
- Browser
- Download file 1.01 kB
-
https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/pool/shard011/Python/0096561_v_function.py
- Command line
-
hf download hf://datasets/Variable-role/sajaniemi_variable_dataset_large/pool/shard011/Python/0096561_v_function.py
-
curl -L -o 0096561_v_function.py https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/pool/shard011/Python/0096561_v_function.py
1.01 kB
| import chainer | |
| from chainer import functions as F | |
| from chainer import links as L | |
| class VFunction(object): | |
| pass | |
| class FCVFunction(chainer.ChainList, VFunction): | |
| def __init__(self, n_input_channels, n_hidden_layers=0, | |
| n_hidden_channels=None): | |
| self.n_input_channels = n_input_channels | |
| self.n_hidden_layers = n_hidden_layers | |
| self.n_hidden_channels = n_hidden_channels | |
| layers = [] | |
| if n_hidden_layers > 0: | |
| layers.append(L.Linear(n_input_channels, n_hidden_channels)) | |
| for i in range(n_hidden_layers - 1): | |
| layers.append(L.Linear(n_hidden_channels, n_hidden_channels)) | |
| layers.append(L.Linear(n_hidden_channels, 1)) | |
| else: | |
| layers.append(L.Linear(n_input_channels, 1)) | |
| super(FCVFunction, self).__init__(*layers) | |
| def __call__(self, state): | |
| h = state | |
| for layer in self[:-1]: | |
| h = F.relu(layer(h)) | |
| h = self[-1](h) | |
| return h | |