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
  • About
  • Contact

Theme Settings

Color Scheme
Display Options
Font Size
100%
Back to Project
RSK World
tensorflow-deeplearning
/
tests
RSK World
tensorflow-deeplearning
Deep learning with TensorFlow and Keras
tests
  • __init__.py159 B
  • test_cnns.py1.4 KB
  • test_neural_networks.py1.7 KB
01_neural_networks.ipynbtest_neural_networks.py
notebooks/01_neural_networks.ipynb
Raw Download
Find: Go to:
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Neural Networks 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 basic neural network construction using 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",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "from neural_networks import (\n",
    "    create_simple_neural_network,\n",
    "    create_deep_neural_network,\n",
    "    train_model,\n",
    "    plot_training_history\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Load and Preprocess Data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Load MNIST dataset\n",
    "(X_train, y_train), (X_test, y_test) = keras.datasets.mnist.load_data()\n",
    "\n",
    "# Preprocess data\n",
    "X_train = X_train.reshape(60000, 784).astype('float32') / 255.0\n",
    "X_test = X_test.reshape(10000, 784).astype('float32') / 255.0\n",
    "\n",
    "print(f\"Training samples: {X_train.shape[0]}\")\n",
    "print(f\"Test samples: {X_test.shape[0]}\")\n",
    "print(f\"Input shape: {X_train.shape[1:]}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Create Simple Neural Network"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Create simple neural network\n",
    "model = create_simple_neural_network(input_shape=(784,), num_classes=10)\n",
    "\n",
    "# Display model architecture\n",
    "model.summary()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Train the Model"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Train model\n",
    "history = train_model(\n",
    "    model, X_train, y_train, X_test, y_test,\n",
    "    epochs=10, batch_size=128\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Visualize Training History"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Plot training history\n",
    "plot_training_history(history)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Create Deep Neural Network"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Create deep neural network\n",
    "deep_model = create_deep_neural_network(\n",
    "    input_shape=(784,),\n",
    "    num_classes=10,\n",
    "    hidden_layers=[256, 128, 64]\n",
    ")\n",
    "\n",
    "deep_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
}
164 lines•3.5 KB
json
tests/test_neural_networks.py
Raw Download
Find: Go to:
"""
Tests for Neural Networks Module
Author: RSK World
Website: https://rskworld.in
Email: help@rskworld.in
Phone: +91 93305 39277
"""

import unittest
import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))

import numpy as np
from src.neural_networks import (
    create_simple_neural_network,
    create_deep_neural_network
)

class TestNeuralNetworks(unittest.TestCase):
    """Test cases for neural networks module."""
    
    def test_create_simple_neural_network(self):
        """Test simple neural network creation."""
        model = create_simple_neural_network(input_shape=(784,), num_classes=10)
        self.assertIsNotNone(model)
        self.assertEqual(model.input_shape, (None, 784))
        self.assertEqual(model.output_shape, (None, 10))
    
    def test_create_deep_neural_network(self):
        """Test deep neural network creation."""
        model = create_deep_neural_network(
            input_shape=(784,),
            num_classes=10,
            hidden_layers=[256, 128, 64]
        )
        self.assertIsNotNone(model)
        self.assertEqual(model.input_shape, (None, 784))
        self.assertEqual(model.output_shape, (None, 10))
    
    def test_model_prediction(self):
        """Test model prediction."""
        model = create_simple_neural_network(input_shape=(784,), num_classes=10)
        test_input = np.random.randn(1, 784).astype('float32')
        prediction = model.predict(test_input, verbose=0)
        self.assertEqual(prediction.shape, (1, 10))
        self.assertAlmostEqual(np.sum(prediction[0]), 1.0, places=5)

if __name__ == '__main__':
    unittest.main()
51 lines•1.7 KB
python

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