资源算法nninit

nninit

2019-09-18 | |  154 |   0 |   0

nninit

Weight initialization schemes for PyTorch nn.Modules. This is a port of the popular nninit for Torch7 by @kaixhin.

Update

This repo has been merged into PyTorch's nn module, I recommend you use that version going forward.

PyTorch Example

import nninitfrom torch import nnimport torch.nn.init as initimport numpy as npclass Net(nn.Module):
  def __init__(self):
     super(Net, self).__init__()
     self.conv1 = nn.Conv2d(5, 10, (3, 3))
     init.xavier_uniform(self.conv1.weight, gain=np.sqrt(2))
     init.constant(self.conv1.bias, 0.1)network = Net()

Installation

Clone the repo and run python setup install

Usage

import nninitfrom torch import nnimport numpy as npclass Net(nn.Module):
  def __init__(self):
     super(Net, self).__init__()
     self.conv1 = nn.Conv2d(5, 10, (3, 3))
     nninit.xavier_uniform(self.conv1.weight, gain=np.sqrt(2))
     nninit.constant(self.conv1.bias, 0.1)network = Net()

Supported Schemes


上一篇:Character-level convolutional neural nets for text classification

下一篇:E2FAR

用户评价
全部评价

热门资源

  • DuReader_QANet_BiDAF

    Machine Reading Comprehension on DuReader Usin...

  • ETD_cataloguing_a...

    ETD catalouging project using allennlp

  • allennlp_extras

    allennlp_extras Some utilities build on top of...

  • allennlp-dureader

    An Apache 2.0 NLP research library, built on Py...

  • allennlp-server

    allennlp-server Serve allennlp services as sep...