Advanced Search
Search Results
99 total results found
Changing the active file
To change the active file, you can use the switch_to_file method: File.switch_to_file(filename, filetype=None) # You can also call Node.switch_to_file for initialized Nodes. If the filetype parameter is set to None, then the filetype will be inferred. This...
Reloading/retrieving the data from the file
To reload the data from the file, use the following method: File.reload() This method is only 1 line of code: self.data = self.read_data() The read_data method returns the data stored in the file, after being parsed into a python dictionary.
Moving beyond a single flat file
For more complex projects, a flat-file database may not be the way to go. Here is one example of how you could store data in a more distributed way: db folder users user1.pyn user2.pyn etc transactions 001.pyn 002.pyn etc config.json ...
How to fix pyntree installing as UNKNOWN-0.0.0
pip install --upgrade pip wheel setuptools
Installing
pyntree is available via pip: pip install pyntree That's it!
Encrypting a file
Encryption is a new feature as of 1.0.0! To use encryption, first type pip install pyntree[encryption] to install the necessary dependencies. To encrypt your data, simply specify a password parameter for the Node when saving or loading. db = Node('encrypted...
Getting the name of a Node
Syntax: Node._name Let's say you have a miscellaneous Node that got passed to a function somehow. What is its purpose? The name of the Node may shed some light on this: from pyntree import Node x = Node('test.pyn') x._name # 'test.pyn' x.a = 1 x.a._n...
Creating a layer
Function Signature def add_dense( neurons: int, activation: str = 'sigmoid', dropout: float = 0., l1_penalty: float = 0., l2_penalty: float = 0. ) -> None: Parameters neurons (int): The number of neurons in the dense layer. Req...
Configuring Loss/Optimizers
Function Signature def config( optimizer: str = 'gradient descent', loss: str = 'mean square error' ) -> None: Parameters optimizer (str, default='gradient descent'): The optimizer to use during training. Currently, deeprai is in beta, so the...
Training a network
Function Signature def train_model( train_inputs: np.ndarray, train_targets: np.ndarray, test_inputs: np.ndarray, test_targets: np.ndarray, batch_size: int = 36, epochs: int = 500, learning_rate: float = 0.1, momentum: ...
Running data through a network
Function Signature def run( self, inputs: np.ndarray ) -> np.ndarray: Parameters inputs (np.ndarray): The input data to run through the network. This should be a numpy array of shape (input_shape,). Return Value output (np.ndarray): The o...
Viewing network information
Function Signature def specs(self) -> str: Return Value output (str): A string representation of the network information, including the model type, optimizer, parameters, loss function, and DeeprAI version. Description The specs function returns a str...
Graphing
Function Signature def graph(self, metric: str = "cost") -> None: Parameters metric (str, optional): The metric to plot. Default is "cost". Valid metrics are "cost", "acc", or "accuracy", and "error". Return Value None Description The graph func...
The where() method
Syntax: Node.where(**kwargs) Let's say you have a lot of users, sorted by IDs. Now, you want to find a user with a specific, unique email. Sounds like a pain, right? Nope. Here's how to do it with pyntree: db = Node("users.pyn") my_user = db.where(email=...
Converting back to a dictionary
Syntax: dict(Node) This is pretty straightforward, as shown above. The command will make a new dictionary. If you want to directly manipulate a Node's data instead, you can simply perform methods on the called function, as shown in the section Math and obj...
Node representation
Syntax: str(Node) # or repr(Node) str(Node) will return a string representation of the data stored within the Node repr(Node) will return the same as str(Node), but wrapped within the text "Node()"
Math and object manipulation
Syntax: Node += val Math operations If you used pyndb, you probably had to do something like this: x = PYNDatabase({}) x.set("a", 1) x.set("a", x.a.val + 1) Let's be real here, this SUCKS. pyntree does it better: x = Node() x.a = 1 x.a += 1 Wow, t...
Getting the children
Syntax: Node._children The ._children property returns a list of Node objects (the children of the parent Node)
Positional Embedding
Function Signature def embed_position(sequence: np.ndarray) -> np.ndarray: Parameters sequence (np.ndarray): A 2D numpy array where the first dimension represents the sequence length and the second represents the embedding dimension. Return Value...
Word Vecrotization
Module Import: from deeprai.embedding import word_vectorize Class Definition: class WordVectorizer: Initialization: The WordVectorizer is initialized with an optional corpus, which is used for TF-IDF computations. def __init__(self, corpus=...