tensorflow

why set return_sequences=True and stateful=True for tf.keras.layers.LSTM?

为君一笑 提交于 2021-02-17 16:38:22
问题 I am learning tensorflow2.0 and follow the tutorial. In the rnn example, I found the code: def build_model(vocab_size, embedding_dim, rnn_units, batch_size): model = tf.keras.Sequential([ tf.keras.layers.Embedding(vocab_size, embedding_dim, batch_input_shape=[batch_size, None]), tf.keras.layers.LSTM(rnn_units, return_sequences=True, stateful=True, recurrent_initializer='glorot_uniform'), tf.keras.layers.Dense(vocab_size) ]) return model My question is: why the code set the argument return

why set return_sequences=True and stateful=True for tf.keras.layers.LSTM?

不问归期 提交于 2021-02-17 16:36:26
问题 I am learning tensorflow2.0 and follow the tutorial. In the rnn example, I found the code: def build_model(vocab_size, embedding_dim, rnn_units, batch_size): model = tf.keras.Sequential([ tf.keras.layers.Embedding(vocab_size, embedding_dim, batch_input_shape=[batch_size, None]), tf.keras.layers.LSTM(rnn_units, return_sequences=True, stateful=True, recurrent_initializer='glorot_uniform'), tf.keras.layers.Dense(vocab_size) ]) return model My question is: why the code set the argument return

How to avoid overfitting on a simple feed forward network

放肆的年华 提交于 2021-02-17 14:53:46
问题 Using the pima indians diabetes dataset I'm trying to build an accurate model using Keras. I've written the following code: # Visualize training history from keras import callbacks from keras.layers import Dropout tb = callbacks.TensorBoard(log_dir='/.logs', histogram_freq=10, batch_size=32, write_graph=True, write_grads=True, write_images=False, embeddings_freq=0, embeddings_layer_names=None, embeddings_metadata=None) # Visualize training history from keras.models import Sequential from

How to use Keras' predict_on_batch in tf.data.Dataset.map()?

只谈情不闲聊 提交于 2021-02-17 04:55:54
问题 I would like to find a way to use Keras' predict_on_batch inside tf.data.Dataset.map() in TF2.0. Let's say I have a numpy dataset n_data = 10**5 my_data = np.random.random((n_data,10,1)) my_targets = np.random.randint(0,2,(n_data,1)) data = ({'x_input':my_data}, {'target':my_targets}) and a tf.keras model x_input = Input((None,1), name = 'x_input') RNN = SimpleRNN(100, name = 'RNN')(x_input) dense = Dense(1, name = 'target')(RNN) my_model = Model(inputs = [x_input], outputs = [dense]) my

保姆教程 | YOLOv5在建筑工地中安全帽佩戴检测的应用

孤街浪徒 提交于 2021-02-17 04:31:21
点击上方 “ 机器学习与生成对抗网络 ”,关注"星标" 获取有趣、好玩的前沿干货! 教程来自: https://github.com/PeterH0323/Smart_Construction 编辑:AI深度前沿视线 一、YOLO v5训练自己数据集教程 1.1 创建自己的数据集配置文件 1.2 创建每个图片对应的标签文件 1.3 文件放置规范 1.4 聚类得出先验框(可选) 1.5 选择一个你需要的模型 1.6 开始训练 1.7 看训练之后的结果 二、侦测 三、检测危险区域内是否有人 3.1 危险区域标注方式 3.2 执行侦测 3.3 效果:在危险区域里面的人体会被 红色框 选出来 四、生成 ONNX 五、增加数据集的分类 该项目是使用 YOLOv5 v2.x 来训练在智能工地安全领域中头盔目标检测的应用,先来一波演示! 指标 yolov5s 为基础训练, epoch = 50 分类 P R mAP0.5 总体 0.884 0.899 0.888 人体 0.846 0.893 0.877 头 0.889 0.883 0.871 安全帽 0.917 0.921 0.917 对应的 权重文件 :https://pan.baidu.com/share/init?surl=ELPhtW-Q4G8UqEr4YrV_5A,提取码: b981 yolov5m 为基础训练, epoch =

Unable to make predictions on google cloud ml, whereas same model is working on the local machine

梦想与她 提交于 2021-02-17 03:55:06
问题 I am trying to train a machine learning model usinf tensorflow library in the google cloud. I am able to train the model in the cloud after creating a bucket. I am facing the issue when I am tring to make predictions using the existing model. The code and the data is available in the following Github directory. https://github.com/terminator172/game-price-predictions The tensorflow version on the cloud is 1.8 and the tensorflow version on my system is also 1.8 I tried to make predictions by

Unable to make predictions on google cloud ml, whereas same model is working on the local machine

落花浮王杯 提交于 2021-02-17 03:54:51
问题 I am trying to train a machine learning model usinf tensorflow library in the google cloud. I am able to train the model in the cloud after creating a bucket. I am facing the issue when I am tring to make predictions using the existing model. The code and the data is available in the following Github directory. https://github.com/terminator172/game-price-predictions The tensorflow version on the cloud is 1.8 and the tensorflow version on my system is also 1.8 I tried to make predictions by

Fail to find the dnn implementation for LSTM

梦想的初衷 提交于 2021-02-17 03:27:06
问题 I'm trying to run a simple LSTM model with following code model = tf.keras.models.Sequential() model.add(tf.keras.layers.LSTM(32, input_shape=x_train_single.shape[-2:])) model.add(tf.keras.layers.Dense(1)) model.compile(optimizer=tf.keras.optimizers.RMSprop(), loss='mae') single_step_history = model.fit(train_data_single, epochs=EPOCHS, steps_per_epoch=EVALUATION_INTERVAL) The error happened when it trying to fit the model tensorflow.python.framework.errors_impl.UnknownError: [_Derived_] Fail

flink-training-course

亡梦爱人 提交于 2021-02-16 23:40:53
flink-training-course [toc] 转载自 https://github.com/flink-china/flink-training-course 大数据领域顶级盛会 Flink Forward Asia 2019 详情🔎 https://dwz.cn/ioH4FiMZ 直击 Flink Forward Berlin 2019 现场回放!精彩 https://www.bilibili.com/video/av71517088/ 课程简介:本系列课程由 Apache Flink Community China 官方出品。旨在为具备一定大数据基础、对Apache Flink感兴趣的同学提供系统性的入门教程,课程路径为“基础篇>>进阶篇>>运维篇>>实战篇>>源码篇”。 「彩蛋」 Apache Flink 中文邮件列表使用方式 视频 S3 实战&运维篇(进行中) 备注:S1 S2 基础篇+进阶篇本页下滑可见 3.1 Flink 反压/延时监控和调参控制 PPT 视频回放 讲师:Rong Rong(Apache Flink Committer,Software Engineer at Uber) 3.2 Metric 指标、监控、报警 PPT 视频回放 讲师:孙梦瑶(美团点评研发工程师) 3.3 如何利用 Flink 和深度学习模型实现垃圾图片分类(Apache

TypeError: tuple indices must be integers or slices, not list - While loading a model Keras

£可爱£侵袭症+ 提交于 2021-02-16 22:03:14
问题 In short, i have 2 trained models, one trained on 2 classes, the other on 3 classes. My code loads a model, loads an image, and predicts a classification result. finetune_model = tf.keras.models.load_model(modelPath) model = load_model(my_file) img = image.load_img(img_path, target_size=(img_width, img_height)) x = image.img_to_array(img) x = np.expand_dims(x, axis=0) x = preprocess_input(x) preds = model.predict(x) The model file is of .h5 type. When loading the 2-class trained model, it