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
def get_layer(self, cols, rows): """Return a layer.""" return AnalogLinear( cols, rows, bias=True, resistive_device=FloatingPointResistiveDevice()).cuda()
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()
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())
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
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)
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()