pub struct DenseLayer {
pub(crate) inner: DenseLayer,
}Fields§
§inner: DenseLayerImplementations§
Source§impl DenseLayer
impl DenseLayer
pub(crate) fn new( n_inputs: usize, n_neurons: usize, length: usize, seed: u64, ) -> Self
pub(crate) fn get_weights(&self) -> Vec<Vec<f64>>
pub(crate) fn set_weights(&mut self, weights: Vec<Vec<f64>>) -> PyResult<()>
pub(crate) fn refresh_packed_weights(&mut self)
pub(crate) fn forward( &self, input_values: Vec<f64>, seed: u64, ) -> PyResult<Vec<f64>>
pub(crate) fn forward_fast( &self, input_values: Vec<f64>, seed: u64, ) -> PyResult<Vec<f64>>
Sourcepub(crate) fn forward_numpy<'py>(
&self,
py: Python<'py>,
input_values: PyReadonlyArray1<'py, f64>,
seed: u64,
) -> PyResult<Bound<'py, PyArray1<f64>>>
pub(crate) fn forward_numpy<'py>( &self, py: Python<'py>, input_values: PyReadonlyArray1<'py, f64>, seed: u64, ) -> PyResult<Bound<'py, PyArray1<f64>>>
Dense forward accepting numpy input and returning numpy output.
This performs parallel encoding + parallel compute in one FFI call.
Sourcepub(crate) fn forward_batch_numpy<'py>(
&self,
py: Python<'py>,
inputs: PyReadonlyArray2<'py, f64>,
seed: u64,
) -> PyResult<Bound<'py, PyArray2<f64>>>
pub(crate) fn forward_batch_numpy<'py>( &self, py: Python<'py>, inputs: PyReadonlyArray2<'py, f64>, seed: u64, ) -> PyResult<Bound<'py, PyArray2<f64>>>
Dense forward for a batch of input samples in one FFI call.
inputs must be a contiguous float64 array of shape (n_samples, n_inputs).
Returns float64 array of shape (n_samples, n_neurons).
Sourcepub(crate) fn forward_prepacked(
&self,
packed_inputs: &Bound<'_, PyAny>,
) -> PyResult<Vec<f64>>
pub(crate) fn forward_prepacked( &self, packed_inputs: &Bound<'_, PyAny>, ) -> PyResult<Vec<f64>>
Forward pass with pre-packed input bitstreams.
Accepts either:
- 2-D numpy array of dtype uint64 with shape (n_inputs, words)
- list[list[int]]
Sourcepub(crate) fn forward_prepacked_numpy<'py>(
&self,
py: Python<'py>,
packed_inputs: PyReadonlyArray2<'py, u64>,
) -> PyResult<Bound<'py, PyArray1<f64>>>
pub(crate) fn forward_prepacked_numpy<'py>( &self, py: Python<'py>, packed_inputs: PyReadonlyArray2<'py, u64>, ) -> PyResult<Bound<'py, PyArray1<f64>>>
Dense forward with pre-packed numpy 2-D input (true zero-copy).
Accepts a contiguous numpy uint64 array of shape (n_inputs, words).
This avoids all row-copying that the forward_prepacked method does.
Trait Implementations§
Source§impl<'py> IntoPyObject<'py> for DenseLayer
impl<'py> IntoPyObject<'py> for DenseLayer
Source§type Target = DenseLayer
type Target = DenseLayer
Source§type Output = Bound<'py, <DenseLayer as IntoPyObject<'py>>::Target>
type Output = Bound<'py, <DenseLayer as IntoPyObject<'py>>::Target>
Source§fn into_pyobject(
self,
py: Python<'py>,
) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
fn into_pyobject( self, py: Python<'py>, ) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
Source§impl PyClass for DenseLayer
impl PyClass for DenseLayer
Source§impl PyClassImpl for DenseLayer
impl PyClassImpl for DenseLayer
Source§const IS_BASETYPE: bool = false
const IS_BASETYPE: bool = false
Source§const IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
Source§const IS_MAPPING: bool = false
const IS_MAPPING: bool = false
Source§const IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
Source§const IS_IMMUTABLE_TYPE: bool = false
const IS_IMMUTABLE_TYPE: bool = false
Source§const RAW_DOC: &'static CStr = c"\x00"
const RAW_DOC: &'static CStr = c"\x00"
Source§const DOC: &'static CStr
const DOC: &'static CStr
text_signature if a constructor is defined. Read moreSource§type Layout = <<DenseLayer as PyClassImpl>::BaseNativeType as PyClassBaseType>::Layout<DenseLayer>
type Layout = <<DenseLayer as PyClassImpl>::BaseNativeType as PyClassBaseType>::Layout<DenseLayer>
Source§type ThreadChecker = NoopThreadChecker
type ThreadChecker = NoopThreadChecker
Source§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
Source§type BaseNativeType = PyAny
type BaseNativeType = PyAny
PyAny by default, and when you declare
#[pyclass(extends=PyDict)], it’s PyDict.fn items_iter() -> PyClassItemsIter
fn lazy_type_object() -> &'static LazyTypeObject<Self>
§fn dict_offset() -> Option<PyObjectOffset>
fn dict_offset() -> Option<PyObjectOffset>
§fn weaklist_offset() -> Option<PyObjectOffset>
fn weaklist_offset() -> Option<PyObjectOffset>
Source§impl PyClassNewTextSignature for DenseLayer
impl PyClassNewTextSignature for DenseLayer
const TEXT_SIGNATURE: &'static str = "(n_inputs, n_neurons, length=1024, seed=24301)"
Source§impl PyMethods<DenseLayer> for PyClassImplCollector<DenseLayer>
impl PyMethods<DenseLayer> for PyClassImplCollector<DenseLayer>
fn py_methods(self) -> &'static PyClassItems
Source§impl PyTypeInfo for DenseLayer
impl PyTypeInfo for DenseLayer
Source§const NAME: &str = <Self as ::pyo3::PyClass>::NAME
const NAME: &str = <Self as ::pyo3::PyClass>::NAME
prefer using ::type_object(py).name() to get the correct runtime value
Source§const MODULE: Option<&str> = <Self as ::pyo3::impl_::pyclass::PyClassImpl>::MODULE
const MODULE: Option<&str> = <Self as ::pyo3::impl_::pyclass::PyClassImpl>::MODULE
prefer using ::type_object(py).module() to get the correct runtime value
Source§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
§fn type_object(py: Python<'_>) -> Bound<'_, PyType>
fn type_object(py: Python<'_>) -> Bound<'_, PyType>
§fn is_type_of(object: &Bound<'_, PyAny>) -> bool
fn is_type_of(object: &Bound<'_, PyAny>) -> bool
object is an instance of this type or a subclass of this type.§fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool
fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool
object is an instance of this type.impl DerefToPyAny for DenseLayer
impl ExtractPyClassWithClone for DenseLayer
Auto Trait Implementations§
impl Freeze for DenseLayer
impl RefUnwindSafe for DenseLayer
impl Send for DenseLayer
impl Sync for DenseLayer
impl Unpin for DenseLayer
impl UnsafeUnpin for DenseLayer
impl UnwindSafe for DenseLayer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
§fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
self into an owned Python object, dropping type information.§fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>
fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>
self into an owned Python object, dropping type information and unbinding it
from the 'py lifetime.§fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>
fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>
self into a Python object. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PyErrArguments for T
impl<T> PyErrArguments for T
§impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
§const NAME: &'static str = T::NAME
const NAME: &'static str = T::NAME
Use ::classinfo_object() instead and format the type name at runtime. Note that using built-in cast features is often better than manual PyTypeCheck usage.
§fn type_check(object: &Bound<'_, PyAny>) -> bool
fn type_check(object: &Bound<'_, PyAny>) -> bool
§fn classinfo_object(py: Python<'_>) -> Bound<'_, PyAny>
fn classinfo_object(py: Python<'_>) -> Bound<'_, PyAny>
isinstance and issubclass function. Read more