0%

设置GPU

1
2
3
from tensorflow.config.experimental import list_physical_devices, set_memory_growth
physical_devices = list_physical_devices('GPU')
set_memory_growth(physical_devices[0], True)
1
2
3
4
5
6
import os
import time
import numpy as np
import matplotlib.pyplot as plt
import cv2
import tqdm # 进度条工具
阅读全文 »

设置GPU

1
2
from tensorflow.config.experimental import list_physical_devices, set_memory_growth
physical_devices = list_physical_devices('GPU')
1
physical_devices
[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
1
set_memory_growth(physical_devices[0], True)
阅读全文 »

中阶API

激活函数

一般作用于单个神经元结构的输出,我们需要利用非线性激活函数向模型中引入非线性特征,用来拟合非线性数据

1
from tensorflow.keras import activations
1
2
3
# activations.sigmoid()
# activations.relu()
# activations.softmax()
阅读全文 »

1
2
import tensorflow as tf
import numpy as np
1
2
# 查看tensorflow2的版本,注意双下划线
tf.__version__
'2.9.1'
1
2
# 查看电脑GPU是否可用   cuda  cudnn
tf.test.is_gpu_available()
False
阅读全文 »

目标网址

经过对网页资源的分析,我们发现,今日头条表情包在网页中的加载方式有两种。

  1. 刚刚打开网页时得到的图片数据是静态加载的。
  2. 随着鼠标网页滑动又会动态的加载出其他的表情包。

说明:今日头条表情包的数据加载方式是有两种的,静态加载和动态加载。

阅读全文 »

获取华中杯首页最新通知标题

1
import requests
1
url = 'http://hzbmmc.com:8080/jeecg-boot/api/v1/webbaseinfo/announcement/brief?mentTypehzbWebbaseinfoAnnounce=1&queryPage=1&querySize=5'
1
response = requests.get(url)
阅读全文 »

1
import requests

发送get请求

1
2
# 设置请求的网址
url = "http://hzbmmc.com/"
1
2
# 发送get请求
response = requests.get(url)
1
2
# 查看响应的状态码
response.status_code
200
阅读全文 »