Eternal AI
  • The AI layer for the new internet
  • eternals
    • What are Eternals?
    • Specification
    • Proof-of-Compute
  • The new internet, AI-powered
    • Bitcoin, AI-powered
      • Eternals on Bitcoin
      • BitAI Virtual Machine
      • Run a BitAI node
    • Ethereum, AI-powered
    • Solana, AI-powered
  • smart contracts, ai-powered
    • How to use onchain LLM
    • Onchain AI composability - AI Powered Wallet
    • Onchain AI Composability - AI Powered Gaming With Chess
  • neurons
    • What are Neurons?
    • Neuron Device
    • Virtual Neurons
      • Solo Neuron
      • Neuron as a Service
      • Pooled Neuron
  • AI CHAINS
    • What are AI chains?
    • Bittensor and existing concepts
    • Base layer: Bitcoin vs Bittensor
    • AI chains: Bitcoin L2s vs Subnets
    • Apps: Smart contracts vs APIs
  • EAI
    • Utilities
    • Tokenomics
  • fully onchain ai models
    • Architecture
    • Deploy your first fully onchain AI
      • Set up your development environment
      • Create a self-custody wallet
      • Train an AI model in Keras
      • Transform the Keras model to Eternal
      • Send, receive, and trade Eternals
    • Progress
    • Misc
      • Transforming an AI Model into an Eternal
      • Standardized data formats
      • Specification
        • Layers
        • Models
  • Decentralized Inference API
    • API
      • API Key
      • Completions
      • Chat completion
      • Create a dagent
      • Get deposit address
      • Get dagent info
      • Agent Completion
    • Onchain Models
    • Tutorials
      • Build unstoppable Eliza agents
      • Build unstoppable Rig agents
      • Build unstoppable ZerePy agents
      • Decentralized ChatGPT
      • Don't Trust, Verify
      • Adjust your dagent personality
      • Launch on Twitter
      • Chain of thought
      • Build a dagent as a service with EternalAI API
    • Open Source
      • Architecture
      • Installation
Powered by GitBook
On this page
  • Download a pre-trained AI model
  • Train your own AI model in Keras
  1. fully onchain ai models
  2. Deploy your first fully onchain AI

Train an AI model in Keras

PreviousCreate a self-custody walletNextTransform the Keras model to Eternal

Last updated 10 months ago

Download a pre-trained AI model

We're making it easy for you. If you have never trained an AI model before, you can download a simple pre-trained AI model .

Once you're familiar with the Eternal AI Toolkit, you can play around with the more sophisticated models from popular AI community sites like Kaggle and Hugging Face. There are thousands of AI models published by AI enthusiasts and researchers around the world.

Train your own AI model in Keras

With the Eternal AI Python SDK, there is no need to learn new tools or languages like Solidity. You can just train your AI models in Keras as usual. Then, transform them into Eternals with just a few lines of Python code.

Here is a simple example of training an AI model to recognize handwritten digits.

import eai
from keras import layers, models, datasets

# Load MNIST data
(train_images, train_labels), _ = datasets.mnist.load_data()
train_images = train_images[:1000].reshape((1000, 28, 28, 1)) / 255

# Define a simple Keras model
model = models.Sequential([
    layers.Conv2D(8, (3, 3), activation="relu", input_shape=(28, 28, 1)),
    layers.MaxPooling2D((2, 2)),
    layers.Flatten(),
    layers.Dense(10, activation="softmax"),
])
model.compile(optimizer='adam', loss='sparse_categorical_crossentropy')

# Train briefly
model.fit(train_images, train_labels[:1000], epochs=1)

For more code examples, check out the Keras docs.

here
Find Pre-trained Models | KaggleKaggle
Logo
Models - Hugging Facehuggingface
Logo
Keras documentation: Code examples
Logo