flatspin.encoder

Input encoding

Module Contents

Classes

Encoder

Functions

expand_dims(input)

Add a new dimension at the end

check_input(input)

squeeze(input)

Squeeze all but the first axis

scale(input, H0=0, H=1)

Scale input to range [H0, H]

angle(input, phi0=0, phi=360)

Map input to angle in range [phi0, phi] -> vector components

angle_grid(input, phi0=0, phi=360, grid=None)

Convenience function to offset all angles based on grid

sw(input, rotation=0)

Multiply input vectors by SW astroid

broadcast_waveform(input, waveform)

Broadcast waveform over input

sin(input, timesteps=100)

Multiply input by sine wave

triangle(input, timesteps=100)

Multiply input by triangle wave

rotate(input, timesteps=100)

Multiply input by rotation vector

ppm(input, pos0=0, pos=1.0, timesteps=100)

Pulse position modulation

fixed_vector(input, phi=0)

Convert scalar input to vectors at some angle phi

rotate_vector(input, phi=0)

Rotate vector input by some angle phi

ensure2d(input, fill=1.0)

Convert scalar input to vectors

grid(input, grid_size=(3, 3), grid=None)

Encode input onto grid

onehot(input, nbits=2)

get_encoder(name, **params)

Attributes

encoders

SinEncoder

class flatspin.encoder.Encoder(*steps, verbose=False)
_verbose(self, *args, **kwargs)
encode(self, input, verbose=False)

Encode input stream

input.shape = (n_inputs, input_dim) output.shape = (n_inputs, time, output_dim, …) # step

= (n_inputs, time, 2) # global field = (n_inputs, time, height, width) # local field on grid

__call__(self, input)
static _get_default_params(step)
get_default_params(self)
get_params(self)
set_param(self, name, value)

Set all params matching name

set_params(self, **params)
__repr__(self)

Return repr(self).

flatspin.encoder.expand_dims(input)

Add a new dimension at the end

flatspin.encoder.check_input(input)
flatspin.encoder.squeeze(input)

Squeeze all but the first axis

flatspin.encoder.scale(input, H0=0, H=1)

Scale input to range [H0, H]

flatspin.encoder.angle(input, phi0=0, phi=360)

Map input to angle in range [phi0, phi] -> vector components

flatspin.encoder.angle_grid(input, phi0=0, phi=360, grid=None)

Convenience function to offset all angles based on grid

flatspin.encoder.sw(input, rotation=0)

Multiply input vectors by SW astroid

flatspin.encoder.broadcast_waveform(input, waveform)

Broadcast waveform over input

flatspin.encoder.sin(input, timesteps=100)

Multiply input by sine wave

flatspin.encoder.triangle(input, timesteps=100)

Multiply input by triangle wave

flatspin.encoder.rotate(input, timesteps=100)

Multiply input by rotation vector

flatspin.encoder.ppm(input, pos0=0, pos=1.0, timesteps=100)

Pulse position modulation

flatspin.encoder.fixed_vector(input, phi=0)

Convert scalar input to vectors at some angle phi

flatspin.encoder.rotate_vector(input, phi=0)

Rotate vector input by some angle phi

flatspin.encoder.ensure2d(input, fill=1.0)

Convert scalar input to vectors

flatspin.encoder.grid(input, grid_size=(3, 3), grid=None)

Encode input onto grid

Parameters
  • grid_size (tuple) – Create grid of fixed size (uniform weights) Ignored if grid is set

  • grid (array) – Create grid of given size (non-uniform weights)

flatspin.encoder.onehot(input, nbits=2)
flatspin.encoder.encoders
flatspin.encoder.get_encoder(name, **params)
flatspin.encoder.SinEncoder