Librería para conectarce a ocean protocol y poder crear IA
Project description
Oceanai-py
Wrapper library that allows a direct integration between the Ocean marketplace and artificial intelligence tools like tensorflow
With Oceanai-py, you can:
-
Create artificial intelligence models: the current state of the library uses Tensorflow for the implementation of the AI models, anything that you can do with Tensorflow you can also do it with Oceanai-py
-
Buy OCEAN marketplace datasets to use them on your models
-
Consume OCEAN datatokens, to access the services of the Ocean environment.
Every function related to the OCEAN environment is fullfiled using Ocean.py. Ocean.py is part of the Ocean Protocol toolset.
This library is still in alpha state and you can expect running into problems.
📚 Prerequisites
- Python (recomended version 3.9) (Install from here)
🏗 Installation
#Is necesary to install tensorflow and ocean-lib separately for aboiding download errors.
pip install oceanai-py
pip install tensorflow
pip install --pre ocean-lib
🏄 Quickstart
The source code of this example is also included on the folder samples of the library
index.py This file explains how to implement several types of AI models for the selected Ocean dataset
import tensorflow as tf
from model_goal import ModelGoal
from src.ia.tensorflow_s.sequential_space import SequentialSpace
from src.ia.tensorflow_s.models.multilayer.multilayer_dataset_parser import MultilayerDataParser
from src.ia.tensorflow_s.multilevel.multilevel_sequential_training import MultilevelSequentialTraining
inputs = [
[ 0.1, 0.3, 0.4, 0.4 ],
[ 0.8, 0.2, 0.2, 0.6 ],
[ 0.2, 0.6, 0.4, 0.3 ],
[ 0.3, 0.8, 0.7, 0.9 ],
[ 0.1, 0.2, 0.3, 0.2 ],
[ 0.4, 0.4, 0.9, 0.1 ],
[ 0.1, 0.3, 0.2, 0.5 ],
[ 0.5, 0.5, 0.3, 0.3 ],
[ 0.7, 0.6, 0.2, 0.5 ],
]
outputs = [
[ 0.25, 0.4 ],
[ 0.5, 0.4 ],
[ 0.5, 0.35 ],
[ 0.55, 0.8 ],
[ 0.15, 0.25 ],
[ 0.4, 0.5 ],
[ 0.4, 0.35 ],
[ 0.5, 0.3 ],
[ 0.65, 0.35 ],
]
args = {
"inputs": 4,
"outputs": 2,
"hidden": [20, 20]
}
compileArgs = {
'optimizer': tf.keras.optimizers.Adamax(learning_rate=1e-3),
'loss': tf.keras.losses.MeanSquaredError(),
'metrics': [tf.keras.metrics.MeanSquaredError()]
}
fitArgs = {
'epochs': 100,
'batchSize': 32
}
iters = 10
goal = ModelGoal(inputs, outputs)
def sample():
layers = [
tf.keras.layers.Dense(units=args['inputs'], input_shape=(args['inputs'],)), # input layer
tf.keras.layers.Dense(units=20 ), # hidden layer 1
tf.keras.layers.Dense(units=20 ), # hidden layer 2
tf.keras.layers.Dense(units=args["outputs"]) # output layer
]
space = SequentialSpace(layers)
parser = MultilayerDataParser(2)
training = MultilevelSequentialTraining(goal, parser, compileArgs, fitArgs,iters)
model = training.apply(space)
print('> outputs: '+str(outputs))
print("> predictions: "+str(model.apply(inputs)))
sample()
Obtaining Ocean datasets
In here we will explain how to obtain OCEAN datasets using oceanai-lib.
from src.ocean.occean import Occean
d = {
'network' : 'https://rinkeby.infura.io/v3/proyectid',
'metadataCacheUri' : 'https://v4.aquarius.oceanprotocol.com',
'providerUri' : 'https://v4.provider.rinkeby.oceanprotocol.com',
}
occean = Occean(d,"private key my account","private key accout buying from")
# create NFT token in the accoutn buying from
data_nft = occean.publishNFTToken('NFTToken1', 'NFT1')
##occean.createDatasetExmple()
# the account we are buying from create the datatoken
datatoken = occean.createDataToken(data_nft,2)
#datatoken = occean.getDatatoken('token address') we can allso get the datatoken
#creat exage id an the buy
exange_id = occean.getExchangeId(datatoken,1,3)
tx_result = occean.buy(datatoken,exange_id,1,2)
📖 Learn more
- Ocean.py - Library for accessing to the OCEAN services
- Tensorflow.js - Tensorflow AI library.
⬆️ Releases
Coming soon.
🏛 License
Copyright ((C)) 2021 Intelligent Trading Machines
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file oceanai-py-0.0.5.tar.gz
.
File metadata
- Download URL: oceanai-py-0.0.5.tar.gz
- Upload date:
- Size: 11.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 718d525a8241c16741eacdb60d07bbbf865e1beef224607ca204f1b999e67aaf |
|
MD5 | 4015b31b232719ebefb1e8ee24023181 |
|
BLAKE2b-256 | a391fd2bb075a26f8a1716dcda1b6dbfce8c790b48d8e28f82b0237e6411c572 |
File details
Details for the file oceanai_py-0.0.5-py3-none-any.whl
.
File metadata
- Download URL: oceanai_py-0.0.5-py3-none-any.whl
- Upload date:
- Size: 19.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7144ade4d5641276960aed6a085d7aa4699d745082dbd49dd39c62d8cc007610 |
|
MD5 | 3055335ccc74e5009fda5f718b9f407d |
|
BLAKE2b-256 | f69c5caa4752319760805d5386dd54663d8e740e43476db53555cade5add34b7 |