help@rskworld.in +91 93305 39277
RSK World
  • Home
  • Development
    • Web Development
    • Mobile Apps
    • Software
    • Games
    • Project
  • Technologies
    • Data Science
    • AI Development
    • Cloud Development
    • Blockchain
    • Cyber Security
    • Dev Tools
    • Testing Tools
  • Blog
  • About
  • Contact

Theme Settings

Color Scheme
Display Options
Font Size
100%
Back to Project
RSK World
tensorflow-deeplearning
/
notebooks
RSK World
tensorflow-deeplearning
Deep learning with TensorFlow and Keras
notebooks
  • 01_neural_networks.ipynb3.5 KB
  • 02_cnns.ipynb3.5 KB
  • 03_rnns.ipynb3.9 KB
  • 04_custom_models.ipynb2.6 KB
04_custom_models.ipynb
notebooks/04_custom_models.ipynb
Raw Download
Find: Go to:
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Custom Layers and Models with TensorFlow\n",
    "\n",
    "<!--\n",
    "Project: TensorFlow Deep Learning\n",
    "Author: RSK World\n",
    "Website: https://rskworld.in\n",
    "Email: help@rskworld.in\n",
    "Phone: +91 93305 39277\n",
    "-->\n",
    "\n",
    "This notebook demonstrates how to create custom layers and models in TensorFlow/Keras."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import sys\n",
    "import os\n",
    "sys.path.append(os.path.join(os.path.dirname(os.getcwd()), 'src'))\n",
    "\n",
    "import tensorflow as tf\n",
    "from tensorflow import keras\n",
    "from tensorflow.keras import layers\n",
    "import numpy as np\n",
    "\n",
    "from custom_layers import (\n",
    "    DenseLayer,\n",
    "    AttentionLayer,\n",
    "    ResidualBlock,\n",
    "    CustomCNNModel,\n",
    "    CustomRNNModel,\n",
    "    create_model_with_custom_layers\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Create Model with Custom Layers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Generate sample data\n",
    "X_train = np.random.randn(1000, 784).astype('float32')\n",
    "y_train = np.random.randint(0, 10, 1000)\n",
    "\n",
    "# Create model with custom layers\n",
    "model = create_model_with_custom_layers(input_shape=(784,), num_classes=10)\n",
    "\n",
    "model.summary()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Train Custom Model"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Train model\n",
    "history = model.fit(\n",
    "    X_train, y_train,\n",
    "    batch_size=32,\n",
    "    epochs=5,\n",
    "    verbose=1\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Create Custom CNN Model"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Create custom CNN model\n",
    "cnn_model = CustomCNNModel(num_classes=10)\n",
    "cnn_model.build(input_shape=(None, 28, 28, 1))\n",
    "cnn_model.summary()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "name": "python",
   "version": "3.8.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
124 lines•2.6 KB
json

About RSK World

Founded by Molla Samser, with Designer & Tester Rima Khatun, RSK World is your one-stop destination for free programming resources, source code, and development tools.

Founder: Molla Samser
Designer & Tester: Rima Khatun

Development

  • Game Development
  • Web Development
  • Mobile Development
  • AI Development
  • Development Tools

Legal

  • Terms & Conditions
  • Privacy Policy
  • Disclaimer

Contact Info

Nutanhat, Mongolkote
Purba Burdwan, West Bengal
India, 713147

+91 93305 39277

hello@rskworld.in
support@rskworld.in

© 2026 RSK World. All rights reserved.

Content used for educational purposes only. View Disclaimer