Пример #1
0
 def get_tile(self, out_size, in_size, device_params=None):
     """Return an floating point tile of the specified dimensions."""
     device_params = device_params or FloatingPointTileParameters()
     resistive_device = FloatingPointResistiveDevice(device_params)
     python_tile = FloatingPointTile(out_size, in_size, resistive_device)
     self.set_init_weights(python_tile)
     return python_tile
Пример #2
0
 def get_layer(self, cols, rows):
     """Return a layer."""
     return AnalogLinear(
         cols,
         rows,
         bias=True,
         resistive_device=FloatingPointResistiveDevice()).cuda()
Пример #3
0
 def get_model(self, **kwargs):
     """Return a layer."""
     if 'resistive_device' not in kwargs:
         kwargs['resistive_device'] = FloatingPointResistiveDevice()
     return AnalogConv2d(in_channels=2,
                         out_channels=3,
                         kernel_size=4,
                         padding=2,
                         **kwargs).cuda()
Пример #4
0
 def get_layer(self,
               in_channels=2,
               out_channels=3,
               kernel_size=4,
               padding=2):
     """Return a layer."""
     return AnalogConv2d(in_channels=in_channels,
                         out_channels=out_channels,
                         kernel_size=kernel_size,
                         padding=padding,
                         bias=True,
                         resistive_device=FloatingPointResistiveDevice())
Пример #5
0
 def __init__(
     self,
     out_size: int,
     in_size: int,
     resistive_device: Optional[FloatingPointResistiveDevice] = None,
     bias: bool = False,
     in_trans: bool = False,
     out_trans: bool = False,
 ):
     self.resistive_device: FloatingPointResistiveDevice = (
         resistive_device or FloatingPointResistiveDevice())
     super().__init__(out_size, in_size, self.resistive_device, bias,
                      in_trans, out_trans)
    def get_tile(self, out_size, in_size):
        """Return a tile of the specified dimensions with noisiness turned off."""
        resistive_device = FloatingPointResistiveDevice()
        python_tile = NumpyFloatingPointTile(out_size, in_size,
                                             resistive_device)

        # Set weights.
        init_weights = uniform(-0.5,
                               0.5,
                               size=(python_tile.out_size,
                                     python_tile.in_size))
        python_tile.set_weights(from_numpy(init_weights))

        return python_tile
Пример #7
0
    def test_simple_device_array(self):
        """Test creating an array from a `FloatingPointResistiveDevice`."""
        resistive_device = FloatingPointResistiveDevice()
        analog_tile = resistive_device.create_tile(2, 4)

        self.assertIsInstance(analog_tile, FloatingPointTile)
Пример #8
0
 def get_model(self, **kwargs):
     """Return a layer."""
     if 'resistive_device' not in kwargs:
         kwargs['resistive_device'] = FloatingPointResistiveDevice()
     return AnalogLinear(in_features=5, out_features=3, **kwargs).cuda()