0%

不同的情况会遇到不同的时间问题:具体时间点、时间间隔、星期等,无时不刻我们在和时间碰撞。

什么是时间戳

时间戳Timestamp是指在一连串的数据中加入辨识文字,如时间或者日期等,用以保障本地数据更新顺序和远程的一致。

unix时间戳是从1970年1月1日(UTC/GMT的午夜)开始所经过的秒数,不考虑闰秒。1970-01-01就是经常我们在MySQL中时间为空的时候,转化空的时间戳之后得到的时间。一个小时表示为UNIX时间戳格式为:3600秒;一天表示为UNIX时间戳为86400秒,闰秒不计算。

阅读全文 »

项目环境介绍

本项目使用的深度学习框架为Tensorflow2,详细环境信息如下:

  • Python=3.8.16
  • Tensorflow=2.9.1
  • keras=2.10.0
  • cudatoolkit=11.3.1
  • cudnn=8.2.1

为了防止因数据集过大导致显存过载,首先配置一下Tensorflow调用GPU的规则,设置为动态显存申请。由于这个配置项必须在代码的最前方声明,故提前说明。

TensorFlow中,GPU内存默认是一次性分配的,这意味着如果模型占用的内存超过可用内存的限制,将无法运行模型,而会出现OOM(Out Of Memory)错误。为了解决这个问题,TensorFlow提供了函数set_memory_growth,它可以让TensorFlow动态分配GPU内存,只使用所需的GPU内存。总之,使用set_memory_growth函数,可以在程序运行时分配所需的GPU内存,而不是在程序启动时将GPU内存分配给TensorFlow,这样可以避免在运行大型模型时出现内存不足的问题。

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)
阅读全文 »

设置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)
阅读全文 »