towhee.functional.mixins.state.StateMixin¶
- class towhee.functional.mixins.state.StateMixin[source]¶
Bases:
object
Mixin for state tracking.
Examples:
>>> from towhee import DataCollection, State >>> from towhee import param_scope >>> dc = DataCollection.range(10).set_state(State(a=1)) >>> dc.get_state() {'a': 1}
>>> dc = dc.map(lambda x: x+1).map(lambda x: x*2) >>> dc.get_state() {'a': 1}
Methods
Get the state storage for DataCollection
Set evaluating mode for stateful operators
Set the state storage for DataCollection
Set training mode for stateful operators
smap
- get_state()[source]¶
Get the state storage for DataCollection
- Returns:
the state storage
- Return type:
State
- set_evaluating(state=None)[source]¶
Set evaluating mode for stateful operators
- Parameters:
state (State, optional) – Update the state storage. Defaults to None.
- Returns:
data collection itself
- Return type:
- set_state(state)[source]¶
Set the state storage for DataCollection
- Parameters:
state (State) – state storage
- Returns:
data collection itself
- Return type: