Tensorflow(三十四) —— GRU

Tensorflow(三十四) —— GRU

import tensorflow as tf 
from tensorflow import keras
import numpy as np
tf.compat.v1.disable_eager_execution()
# 加载数据集
total_words = 10000
(x_train,y_train),(x_test,y_test) = keras.datasets.imdb.load_data(num_words=total_words)
print("train_shape:",x_train.shape,y_train.shape,x_test.shape,y_test.shape)
# 数据预处理
max_len = 80
x_train = keras.preprocessing.sequence.pad_sequences(x_train,maxlen=max_len,\
                                                     padding="post",truncating = "post")
"""
post 为从末尾开始阶段
"""
x_test = keras.preprocessing.sequence.pad_sequences(x_test,maxlen = max_len,\
                                                   padding = "post",truncating = "post")
db_train = tf.data.Dataset.from_tensor_slices((x_train,y_train))
db_test = tf.data.Dataset.from_tensor_slices((x_test,y_test))

def preprocess(x,
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值