You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
1.8 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 31,
"id": "d863e2b2",
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "markdown",
"id": "eb32e860",
"metadata": {},
"source": [
"relu激活函数"
]
},
{
"cell_type": "code",
"execution_count": 32,
"id": "eead13ab",
"metadata": {},
"outputs": [],
"source": [
"inputs = [0, -1, 3, 4, 6, 7]"
]
},
{
"cell_type": "code",
"execution_count": 33,
"id": "307e7d14",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[0, 0, 3, 4, 6, 7]"
]
},
"execution_count": 33,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"outputs = []\n",
"for i in inputs:\n",
" if i > 0:\n",
" outputs.append(i)\n",
" else:\n",
" outputs.append(0)\n",
"outputs"
]
},
{
"cell_type": "code",
"execution_count": 34,
"id": "ef4784b3",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[0, 0, 3, 4, 6, 7]"
]
},
"execution_count": 34,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"outputs = []\n",
"for i in inputs:\n",
" outputs.append(max(0, i))\n",
"outputs"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.9"
}
},
"nbformat": 4,
"nbformat_minor": 5
}