tensorflow 利用tf.dataset.Dataset构建数据batch

tf.dataset.Dataset用过多次了,一直懒得记录,今天来更新下

定义阶段

import tensorflow as tf
import numpy as np
...
def image_read(imnames,labs = None):
    
    print(imnames)
    images = tf.read_file('./reptile/combine_total_224/'+imnames)
    images = tf.image.decode_jpeg(images, channels=3)
    images = tf.image.resize_images(images, [224, 224])
    images = tf.cast(images, tf.float32) / 255.0
    images = tf.multiply(images, 2)
    images = tf.subtract(images, 1.0) 
    return images,labs
    
with tf.name_scope('input'):
    image_x = tf.placeholder(imagename_array.dtype,[None],name='image_x')
    label_y = tf.placeholder(label_agen_array.dtype,[None,7,7,6],name='label_y')
    istraing = tf.placeholder(tf.bool,name='istraing')
    
batch_size = 32
dataset = tf.data.Dataset.from_tensor_slices((image_x, label_y)) #对placeholder元组进行切片
dataset &#
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值