赞
踩
CV之IC之AlexNet:基于tensorflow框架采用CNN卷积神经网络算法(改进的AlexNet,训练/评估/推理)实现猫狗分类识别案例应用
目录
基于tensorflow框架采用CNN(改进的AlexNet,训练/评估/推理)卷积神经网络算法实现猫狗图像分类识别
数据下载:Dogs vs. Cats Redux: Kernels Edition | Kaggle
train文件夹里有25000张狗和猫的图片。这个文件夹中的每个图像都有标签作为文件名的一部分。测试文件夹包含12500张图片,根据数字id命名。对于测试集中的每个图像,您应该预测图像是一只狗的概率(1 =狗,0 =猫)。
序号 | 使用model.ckpt-4000模型预测 | 使用model.ckpt-6000模型预测 | 使用model.ckpt-8000模型预测 | 使用model.ckpt-10000模型预测 | 使用model.ckpt-12000模型预测 | |
1 | cat | cat (1).jpg 猫的概率 0.631 | cat (1).jpg 狗的概率 0.740 | cat (1).jpg 狗的概率 0.781 | cat (1).jpg 狗的概率 0.976 | cat (1).jpg 狗的概率 0.991 |
2 | cat (10).jpg 狗的概率 0.697 | cat (10).jpg 猫的概率 0.566 | cat (10).jpg 猫的概率 0.925 | cat (10).jpg 猫的概率 0.925 | cat (10).jpg 猫的概率 0.816 | |
3 | cat (11).jpg 猫的概率 0.927 | cat (11).jpg 猫的概率 0.988 | cat (11).jpg 猫的概率 1.000 | cat (11).jpg 猫的概率 1.000 | cat (11).jpg 猫的概率 1.000 | |
4 | cat (12).jpg 狗的概率 0.746 | cat (12).jpg 狗的概率 0.723 | cat (12).jpg 狗的概率 0.822 | cat (12).jpg 狗的概率 0.998 | cat (12).jpg 狗的概率 1.000 | |
5 | cat (13).jpg 猫的概率 0.933 | cat (13).jpg 猫的概率 0.983 | cat (13).jpg 猫的概率 0.997 | cat (13).jpg 猫的概率 1.000 | cat (13).jpg 猫的概率 1.000 | |
6 | cat (14).jpg 狗的概率 0.657 | cat (14).jpg 猫的概率 0.597 | cat (14).jpg 狗的概率 0.758 | cat (14).jpg 狗的概率 0.695 | cat (14).jpg 猫的概率 0.544 | |
7 | cat (15).jpg 狗的概率 0.578 | cat (15).jpg 狗的概率 0.535 | cat (15).jpg 狗的概率 0.526 | cat (15).jpg 狗的概率 0.750 | cat (15).jpg 狗的概率 0.569 | |
8 | cat (2).jpg 猫的概率 0.649 | cat (2).jpg 猫的概率 0.637 | cat (2).jpg 猫的概率 0.844 | cat (2).jpg 猫的概率 0.996 | cat (2).jpg 猫的概率 0.998 | |
9 | cat (3).jpg 狗的概率 0.668 | cat (3).jpg 猫的概率 0.538 | cat (3).jpg 猫的概率 0.710 | cat (3).jpg 猫的概率 0.968 | cat (3).jpg 猫的概率 0.995 | |
10 | cat (4).jpg 狗的概率 0.856 | cat (4).jpg 狗的概率 0.780 | cat (4).jpg 狗的概率 0.831 | cat (4).jpg 狗的概率 0.974 | cat (4).jpg 狗的概率 0.976 | |
11 | cat (5).jpg 猫的概率 0.812 | cat (5).jpg 猫的概率 0.776 | cat (5).jpg 猫的概率 0.505 | cat (5).jpg 猫的概率 0.732 | cat (5).jpg 狗的概率 0.608 | |
12 | cat (6).jpg 猫的概率 0.524 | cat (6).jpg 狗的概率 0.661 | cat (6).jpg 狗的概率 0.748 | cat (6).jpg 狗的概率 0.970 | cat (6).jpg 狗的概率 0.987 | |
13 | cat (7).jpg 狗的概率 0.612 | cat (7).jpg 猫的概率 0.845 | cat (7).jpg 猫的概率 0.894 | cat (7).jpg 猫的概率 0.987 | cat (7).jpg 猫的概率 0.728 | |
14 | cat (8).jpg 狗的概率 0.823 | cat (8).jpg 狗的概率 0.948 | cat (8).jpg 狗的概率 0.920 | cat (8).jpg 狗的概率 0.982 | cat (8).jpg 狗的概率 0.999 | |
15 | cat (9).jpg 猫的概率 0.697 | cat (9).jpg 猫的概率 0.704 | cat (9).jpg 狗的概率 0.819 | cat (9).jpg 猫的概率 0.930 | cat (9).jpg 狗的概率 0.718 | |
16 | dog | dog (1).jpg 狗的概率 0.987 | dog (1).jpg 狗的概率 0.995 | dog (1).jpg 狗的概率 0.999 | dog (1).jpg 狗的概率 1.000 | dog (1).jpg 狗的概率 1.000 |
17 | dog (10).jpg 狗的概率 0.628 | dog (10).jpg 猫的概率 0.629 | dog (10).jpg 猫的概率 0.994 | dog (10).jpg 猫的概率 1.000 | dog (10).jpg 猫的概率 1.000 | |
18 | dog (11).jpg 狗的概率 0.804 | dog (11).jpg 狗的概率 0.879 | dog (11).jpg 狗的概率 0.993 | dog (11).jpg 狗的概率 1.000 | dog (11).jpg 狗的概率 1.000 | |
19 | dog (12).jpg 猫的概率 0.704 | dog (12).jpg 猫的概率 0.758 | dog (12).jpg 狗的概率 0.503 | dog (12).jpg 狗的概率 0.653 | dog (12).jpg 猫的概率 0.985 | |
20 | dog (13).jpg 狗的概率 0.987 | dog (13).jpg 狗的概率 0.997 | dog (13).jpg 狗的概率 1.000 | dog (13).jpg 狗的概率 1.000 | dog (13).jpg 狗的概率 1.000 | |
21 | dog (14).jpg 狗的概率 0.815 | dog (14).jpg 狗的概率 0.844 | dog (14).jpg 狗的概率 0.904 | dog (14).jpg 狗的概率 0.996 | dog (14).jpg 狗的概率 0.950 | |
22 | dog (15).jpg 狗的概率 0.917 | dog (15).jpg 狗的概率 0.984 | dog (15).jpg 狗的概率 0.999 | dog (15).jpg 狗的概率 1.000 | dog (15).jpg 狗的概率 1.000 | |
23 | dog (16).jpg 狗的概率 0.883 | dog (16).jpg 狗的概率 0.931 | dog (16).jpg 狗的概率 0.830 | dog (16).jpg 狗的概率 0.975 | dog (16).jpg 狗的概率 0.983 | |
24 | dog (2).jpg 狗的概率 0.934 | dog (2).jpg 狗的概率 0.982 | dog (2).jpg 狗的概率 0.998 | dog (2).jpg 狗的概率 1.000 | dog (2).jpg 狗的概率 1.000 | |
25 | dog (3).jpg 狗的概率 0.993 | dog (3).jpg 狗的概率 1.000 | dog (3).jpg 狗的概率 1.000 | dog (3).jpg 狗的概率 1.000 | dog (3).jpg 狗的概率 1.000 | |
26 | dog (4).jpg 狗的概率 0.693 | dog (4).jpg 狗的概率 0.754 | dog (4).jpg 狗的概率 0.976 | dog (4).jpg 狗的概率 0.515 | dog (4).jpg 狗的概率 0.995 | |
27 | dog (5).jpg 狗的概率 0.916 | dog (5).jpg 狗的概率 0.976 | dog (5).jpg 狗的概率 0.993 | dog (5).jpg 狗的概率 0.998 | dog (5).jpg 狗的概率 1.000 | |
28 | dog (6).jpg 狗的概率 0.947 | dog (6).jpg 狗的概率 0.989 | dog (6).jpg 狗的概率 0.999 | dog (6).jpg 狗的概率 1.000 | dog (6).jpg 狗的概率 1.000 | |
29 | dog (7).jpg 猫的概率 0.526 | dog (7).jpg 猫的概率 0.685 | dog (7).jpg 猫的概率 0.961 | dog (7).jpg 猫的概率 1.000 | dog (7).jpg 猫的概率 1.000 | |
30 | dog (8).jpg 狗的概率 0.981 | dog (8).jpg 狗的概率 0.998 | dog (8).jpg 狗的概率 1.000 | dog (8).jpg 狗的概率 1.000 | dog (8).jpg 狗的概率 1.000 | |
31 | dog (9).jpg 狗的概率 0.899 | dog (9).jpg 狗的概率 0.983 | dog (9).jpg 狗的概率 0.999 | dog (9).jpg 狗的概率 1.000 | dog (9).jpg 狗的概率 1.000 |
- Step 0, train loss = 0.69, train accuracy = 78.12%
- Step 50, train loss = 0.69, train accuracy = 43.75%
- Step 100, train loss = 0.70, train accuracy = 46.88%
- Step 150, train loss = 0.65, train accuracy = 75.00%
- Step 200, train loss = 0.66, train accuracy = 59.38%
- Step 250, train loss = 0.66, train accuracy = 62.50%
- Step 300, train loss = 0.72, train accuracy = 40.62%
- Step 350, train loss = 0.66, train accuracy = 62.50%
- Step 400, train loss = 0.58, train accuracy = 68.75%
- Step 450, train loss = 0.70, train accuracy = 65.62%
- Step 500, train loss = 0.68, train accuracy = 56.25%
- Step 550, train loss = 0.51, train accuracy = 81.25%
- Step 600, train loss = 0.54, train accuracy = 75.00%
- Step 650, train loss = 0.64, train accuracy = 68.75%
- Step 700, train loss = 0.69, train accuracy = 53.12%
- Step 750, train loss = 0.57, train accuracy = 71.88%
- Step 800, train loss = 0.80, train accuracy = 50.00%
- Step 850, train loss = 0.62, train accuracy = 59.38%
- Step 900, train loss = 0.59, train accuracy = 65.62%
- Step 950, train loss = 0.54, train accuracy = 71.88%
- Step 1000, train loss = 0.57, train accuracy = 68.75%
- Step 1050, train loss = 0.56, train accuracy = 78.12%
- Step 1100, train loss = 0.66, train accuracy = 59.38%
- Step 1150, train loss = 0.50, train accuracy = 84.38%
- Step 1200, train loss = 0.46, train accuracy = 81.25%
- Step 1250, train loss = 0.57, train accuracy = 59.38%
- Step 1300, train loss = 0.37, train accuracy = 81.25%
- Step 1350, train loss = 0.64, train accuracy = 62.50%
- Step 1400, train loss = 0.44, train accuracy = 81.25%
- Step 1450, train loss = 0.46, train accuracy = 84.38%
- Step 1500, train loss = 0.50, train accuracy = 71.88%
- Step 1550, train loss = 0.58, train accuracy = 62.50%
- Step 1600, train loss = 0.43, train accuracy = 75.00%
- Step 1650, train loss = 0.55, train accuracy = 71.88%
- Step 1700, train loss = 0.50, train accuracy = 71.88%
- Step 1750, train loss = 0.46, train accuracy = 75.00%
- Step 1800, train loss = 0.81, train accuracy = 53.12%
- Step 1850, train loss = 0.41, train accuracy = 90.62%
- Step 1900, train loss = 0.65, train accuracy = 68.75%
- Step 1950, train loss = 0.37, train accuracy = 84.38%
- Step 2000, train loss = 0.39, train accuracy = 81.25%
- Step 2050, train loss = 0.45, train accuracy = 84.38%
- Step 2100, train loss = 0.44, train accuracy = 78.12%
- Step 2150, train loss = 0.59, train accuracy = 65.62%
- Step 2200, train loss = 0.51, train accuracy = 78.12%
- Step 2250, train loss = 0.42, train accuracy = 81.25%
- Step 2300, train loss = 0.32, train accuracy = 87.50%
- Step 2350, train loss = 0.48, train accuracy = 75.00%
- Step 2400, train loss = 0.54, train accuracy = 71.88%
- Step 2450, train loss = 0.51, train accuracy = 71.88%
- Step 2500, train loss = 0.73, train accuracy = 59.38%
- Step 2550, train loss = 0.52, train accuracy = 78.12%
- Step 2600, train loss = 0.65, train accuracy = 62.50%
- Step 2650, train loss = 0.52, train accuracy = 71.88%
- Step 2700, train loss = 0.48, train accuracy = 71.88%
- Step 2750, train loss = 0.37, train accuracy = 84.38%
- Step 2800, train loss = 0.46, train accuracy = 78.12%
- Step 2850, train loss = 0.40, train accuracy = 84.38%
- Step 2900, train loss = 0.45, train accuracy = 81.25%
- Step 2950, train loss = 0.36, train accuracy = 84.38%
- Step 3000, train loss = 0.46, train accuracy = 75.00%
- Step 3050, train loss = 0.53, train accuracy = 71.88%
- Step 3100, train loss = 0.37, train accuracy = 84.38%
- Step 3150, train loss = 0.53, train accuracy = 75.00%
- Step 3200, train loss = 0.52, train accuracy = 75.00%
- Step 3250, train loss = 0.62, train accuracy = 65.62%
- Step 3300, train loss = 0.58, train accuracy = 71.88%
- Step 3350, train loss = 0.71, train accuracy = 65.62%
- Step 3400, train loss = 0.43, train accuracy = 78.12%
- Step 3450, train loss = 0.46, train accuracy = 78.12%
- Step 3500, train loss = 0.46, train accuracy = 71.88%
- Step 3550, train loss = 0.53, train accuracy = 68.75%
- Step 3600, train loss = 0.44, train accuracy = 75.00%
- Step 3650, train loss = 0.55, train accuracy = 65.62%
- Step 3700, train loss = 0.62, train accuracy = 75.00%
- Step 3750, train loss = 0.48, train accuracy = 75.00%
- Step 3800, train loss = 0.66, train accuracy = 53.12%
- Step 3850, train loss = 0.53, train accuracy = 75.00%
- Step 3900, train loss = 0.36, train accuracy = 81.25%
- Step 3950, train loss = 0.37, train accuracy = 87.50%
- Step 4000, train loss = 0.46, train accuracy = 78.12%
- Step 4050, train loss = 0.36, train accuracy = 84.38%
- Step 4100, train loss = 0.34, train accuracy = 78.12%
- Step 4150, train loss = 0.48, train accuracy = 78.12%
- Step 4200, train loss = 0.43, train accuracy = 87.50%
- Step 4250, train loss = 0.34, train accuracy = 84.38%
- Step 4300, train loss = 0.28, train accuracy = 87.50%
- Step 4350, train loss = 0.19, train accuracy = 96.88%
- Step 4400, train loss = 0.46, train accuracy = 71.88%
- Step 4450, train loss = 0.33, train accuracy = 84.38%
- Step 4500, train loss = 0.55, train accuracy = 75.00%
- Step 4550, train loss = 0.31, train accuracy = 93.75%
- Step 4600, train loss = 0.30, train accuracy = 84.38%
- Step 4650, train loss = 0.38, train accuracy = 84.38%
- Step 4700, train loss = 0.36, train accuracy = 84.38%
- Step 4750, train loss = 0.32, train accuracy = 87.50%
- Step 4800, train loss = 0.36, train accuracy = 81.25%
- Step 4850, train loss = 0.36, train accuracy = 87.50%
- Step 4900, train loss = 0.49, train accuracy = 71.88%
- Step 4950, train loss = 0.51, train accuracy = 68.75%
- Step 5000, train loss = 0.59, train accuracy = 68.75%
- Step 5050, train loss = 0.55, train accuracy = 75.00%
- Step 5100, train loss = 0.71, train accuracy = 68.75%
- Step 5150, train loss = 0.48, train accuracy = 71.88%
- Step 5200, train loss = 0.39, train accuracy = 90.62%
- Step 5250, train loss = 0.49, train accuracy = 81.25%
- Step 5300, train loss = 0.36, train accuracy = 81.25%
- Step 5350, train loss = 0.31, train accuracy = 90.62%
- Step 5400, train loss = 0.39, train accuracy = 87.50%
- Step 5450, train loss = 0.34, train accuracy = 78.12%
- Step 5500, train loss = 0.29, train accuracy = 84.38%
- Step 5550, train loss = 0.21, train accuracy = 93.75%
- Step 5600, train loss = 0.41, train accuracy = 78.12%
- Step 5650, train loss = 0.38, train accuracy = 84.38%
- Step 5700, train loss = 0.27, train accuracy = 87.50%
- Step 5750, train loss = 0.24, train accuracy = 90.62%
- Step 5800, train loss = 0.17, train accuracy = 96.88%
- Step 5850, train loss = 0.23, train accuracy = 93.75%
- Step 5900, train loss = 0.37, train accuracy = 71.88%
- Step 5950, train loss = 0.49, train accuracy = 71.88%
- Step 6000, train loss = 0.43, train accuracy = 81.25%
- Step 6050, train loss = 0.33, train accuracy = 87.50%
- Step 6100, train loss = 0.46, train accuracy = 75.00%
- Step 6150, train loss = 0.61, train accuracy = 81.25%
- Step 6200, train loss = 0.34, train accuracy = 84.38%
- Step 6250, train loss = 0.63, train accuracy = 71.88%
- Step 6300, train loss = 0.21, train accuracy = 90.62%
- Step 6350, train loss = 0.21, train accuracy = 90.62%
- Step 6400, train loss = 0.27, train accuracy = 87.50%
- Step 6450, train loss = 0.17, train accuracy = 87.50%
- Step 6500, train loss = 0.34, train accuracy = 87.50%
- Step 6550, train loss = 0.34, train accuracy = 87.50%
- Step 6600, train loss = 0.32, train accuracy = 84.38%
- Step 6650, train loss = 0.39, train accuracy = 84.38%
- Step 6700, train loss = 0.38, train accuracy = 84.38%
- Step 6750, train loss = 0.41, train accuracy = 84.38%
- Step 6800, train loss = 0.49, train accuracy = 81.25%
- Step 6850, train loss = 0.36, train accuracy = 84.38%
- Step 6900, train loss = 0.20, train accuracy = 93.75%
- Step 6950, train loss = 0.13, train accuracy = 93.75%
- Step 7000, train loss = 0.31, train accuracy = 87.50%
- Step 7050, train loss = 0.18, train accuracy = 93.75%
- Step 7100, train loss = 0.23, train accuracy = 90.62%
- Step 7150, train loss = 0.13, train accuracy = 96.88%
- Step 7200, train loss = 0.14, train accuracy = 96.88%
- Step 7250, train loss = 0.32, train accuracy = 84.38%
- Step 7300, train loss = 0.18, train accuracy = 93.75%
- Step 7350, train loss = 0.14, train accuracy = 100.00%
- Step 7400, train loss = 0.60, train accuracy = 75.00%
- Step 7450, train loss = 0.20, train accuracy = 93.75%
- Step 7500, train loss = 0.13, train accuracy = 93.75%
- Step 7550, train loss = 0.22, train accuracy = 90.62%
- Step 7600, train loss = 0.13, train accuracy = 96.88%
- Step 7650, train loss = 0.20, train accuracy = 93.75%
- Step 7700, train loss = 0.24, train accuracy = 90.62%
- Step 7750, train loss = 0.19, train accuracy = 93.75%
- Step 7800, train loss = 0.16, train accuracy = 93.75%
- Step 7850, train loss = 0.08, train accuracy = 100.00%
- Step 7900, train loss = 0.10, train accuracy = 96.88%
- Step 7950, train loss = 0.13, train accuracy = 93.75%
- Step 8000, train loss = 0.18, train accuracy = 90.62%
- Step 8050, train loss = 0.27, train accuracy = 93.75%
- Step 8100, train loss = 0.04, train accuracy = 100.00%
- Step 8150, train loss = 0.27, train accuracy = 87.50%
- Step 8200, train loss = 0.06, train accuracy = 96.88%
- Step 8250, train loss = 0.12, train accuracy = 100.00%
- Step 8300, train loss = 0.28, train accuracy = 87.50%
- Step 8350, train loss = 0.24, train accuracy = 90.62%
- Step 8400, train loss = 0.16, train accuracy = 93.75%
- Step 8450, train loss = 0.11, train accuracy = 93.75%
- Step 8500, train loss = 0.13, train accuracy = 96.88%
- Step 8550, train loss = 0.05, train accuracy = 100.00%
- Step 8600, train loss = 0.10, train accuracy = 93.75%
- Step 8650, train loss = 0.14, train accuracy = 100.00%
- Step 8700, train loss = 0.21, train accuracy = 90.62%
- Step 8750, train loss = 0.09, train accuracy = 96.88%
- Step 8800, train loss = 0.11, train accuracy = 96.88%
- Step 8850, train loss = 0.10, train accuracy = 96.88%
- Step 8900, train loss = 0.12, train accuracy = 93.75%
- Step 8950, train loss = 0.48, train accuracy = 81.25%
- Step 9000, train loss = 0.07, train accuracy = 100.00%
- Step 9050, train loss = 0.03, train accuracy = 100.00%
- Step 9100, train loss = 0.10, train accuracy = 93.75%
- Step 9150, train loss = 0.05, train accuracy = 96.88%
- Step 9200, train loss = 0.04, train accuracy = 100.00%
- Step 9250, train loss = 0.03, train accuracy = 100.00%
- Step 9300, train loss = 0.04, train accuracy = 96.88%
- Step 9350, train loss = 0.08, train accuracy = 100.00%
- Step 9400, train loss = 0.05, train accuracy = 100.00%
- Step 9450, train loss = 0.15, train accuracy = 90.62%
- Step 9500, train loss = 0.03, train accuracy = 100.00%
- Step 9550, train loss = 0.05, train accuracy = 100.00%
- Step 9600, train loss = 0.15, train accuracy = 96.88%
- Step 9650, train loss = 0.03, train accuracy = 100.00%
- Step 9700, train loss = 0.02, train accuracy = 100.00%
- Step 9750, train loss = 0.08, train accuracy = 96.88%
- Step 9800, train loss = 0.04, train accuracy = 100.00%
- Step 9850, train loss = 0.06, train accuracy = 96.88%
- Step 9900, train loss = 0.03, train accuracy = 100.00%
- Step 9950, train loss = 0.03, train accuracy = 100.00%
- Step 10000, train loss = 0.11, train accuracy = 93.75%
- Step 10050, train loss = 0.02, train accuracy = 100.00%
- Step 10100, train loss = 0.01, train accuracy = 100.00%
- Step 10150, train loss = 0.05, train accuracy = 96.88%
- Step 10200, train loss = 0.07, train accuracy = 96.88%
- Step 10250, train loss = 0.06, train accuracy = 96.88%
- Step 10300, train loss = 0.03, train accuracy = 100.00%
- Step 10350, train loss = 0.08, train accuracy = 96.88%
- Step 10400, train loss = 0.05, train accuracy = 96.88%
- Step 10450, train loss = 0.02, train accuracy = 100.00%
- Step 10500, train loss = 0.22, train accuracy = 93.75%
- Step 10550, train loss = 0.06, train accuracy = 100.00%
- Step 10600, train loss = 0.02, train accuracy = 100.00%
- Step 10650, train loss = 0.02, train accuracy = 100.00%
- Step 10700, train loss = 0.03, train accuracy = 100.00%
- Step 10750, train loss = 0.15, train accuracy = 96.88%
- Step 10800, train loss = 0.05, train accuracy = 100.00%
- Step 10850, train loss = 0.02, train accuracy = 100.00%
- Step 10900, train loss = 0.04, train accuracy = 96.88%
- Step 10950, train loss = 0.05, train accuracy = 96.88%
- Step 11000, train loss = 0.02, train accuracy = 100.00%
- Step 11050, train loss = 0.10, train accuracy = 96.88%
- Step 11100, train loss = 0.08, train accuracy = 96.88%
- Step 11150, train loss = 0.02, train accuracy = 100.00%
- Step 11200, train loss = 0.01, train accuracy = 100.00%
- Step 11250, train loss = 0.06, train accuracy = 96.88%
- Step 11300, train loss = 0.18, train accuracy = 93.75%
- Step 11350, train loss = 0.02, train accuracy = 100.00%
- Step 11400, train loss = 0.04, train accuracy = 100.00%
- Step 11450, train loss = 0.03, train accuracy = 100.00%
- Step 11500, train loss = 0.01, train accuracy = 100.00%
- Step 11550, train loss = 0.02, train accuracy = 100.00%
- weights = tf.get_variable('weights',
- shape=[3, 3, 3, 16],
- dtype=tf.float32,
- initializer=tf.truncated_normal_initializer(stddev=0.1, dtype=tf.float32))
- biases = tf.get_variable('biases',
- shape=[16],
- dtype=tf.float32,
- initializer=tf.constant_initializer(0.1))
- conv = tf.nn.conv2d(images, weights, strides=[1, 1, 1, 1], padding='SAME')
- pre_activation = tf.nn.bias_add(conv, biases)
- conv1 = tf.nn.relu(pre_activation, name=scope.name)
- with tf.variable_scope('pooling1_lrn') as scope:
- pool1 = tf.nn.max_pool(conv1, ksize=[1, 3, 3, 1], strides=[1, 2, 2, 1], padding='SAME', name='pooling1')
- norm1 = tf.nn.lrn(pool1, depth_radius=4, bias=1.0, alpha=0.001 / 9.0, beta=0.75, name='norm1')
-
- with tf.variable_scope('conv2') as scope:
- weights = tf.get_variable('weights',
- shape=[3, 3, 16, 16],
- dtype=tf.float32,
- initializer=tf.truncated_normal_initializer(stddev=0.1, dtype=tf.float32))
- biases = tf.get_variable('biases',
- shape=[16],
- dtype=tf.float32,
- initializer=tf.constant_initializer(0.1))
- conv = tf.nn.conv2d(norm1, weights, strides=[1, 1, 1, 1], padding='SAME')
- pre_activation = tf.nn.bias_add(conv, biases)
- conv2 = tf.nn.relu(pre_activation, name='conv2')
-
-
- with tf.variable_scope('pooling2_lrn') as scope:
- norm2 = tf.nn.lrn(conv2, depth_radius=4, bias=1.0, alpha=0.001 / 9.0, beta=0.75, name='norm2')
- pool2 = tf.nn.max_pool(norm2, ksize=[1, 3, 3, 1], strides=[1, 1, 1, 1], padding='SAME', name='pooling2')
-
- with tf.variable_scope('local3') as scope:
- reshape = tf.reshape(pool2, shape=[batch_size, -1])
- dim = reshape.get_shape()[1].value
- weights = tf.get_variable('weights',
- shape=[dim, 128],
- dtype=tf.float32,
- initializer=tf.truncated_normal_initializer(stddev=0.005, dtype=tf.float32))
- biases = tf.get_variable('biases',
- shape=[128],
- dtype=tf.float32,
- initializer=tf.constant_initializer(0.1))
- local3 = tf.nn.relu(tf.matmul(reshape, weights) + biases, name=scope.name)
-
- # local4
- with tf.variable_scope('local4') as scope:
- weights = tf.get_variable('weights',
- shape=[128, 128],
- dtype=tf.float32,
- initializer=tf.truncated_normal_initializer(stddev=0.005, dtype=tf.float32))
- biases = tf.get_variable('biases',
- shape=[128],
- dtype=tf.float32,
- initializer=tf.constant_initializer(0.1))
- local4 = tf.nn.relu(tf.matmul(local3, weights) + biases, name='local4')
-
-
- with tf.variable_scope('softmax_linear') as scope:
- weights = tf.get_variable('softmax_linear',
- shape=[128, n_classes],
- dtype=tf.float32,
- initializer=tf.truncated_normal_initializer(stddev=0.005, dtype=tf.float32))
- biases = tf.get_variable('biases',
- shape=[n_classes],
- dtype=tf.float32,
- initializer=tf.constant_initializer(0.1))
- softmax_linear = tf.add(tf.matmul(local4, weights), biases, name='softmax_linear')
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。