【OSS】在Mac环境中Python多线程运行报错,是什么原因?
在Mac环境中用Python启动多线程并在子线程中使用OSS时,import tensorflow会报错,没有import tensorflow则不会报错。如果没有启动多线程,使用OSS时import tensorflow不会报错。
objc[2483]: +[__NSPlaceholderDate initialize] may have been in progress in another thread when fork() was called.
objc[2483]: +[__NSPlaceholderDate initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.
TensorFlow图像cifar10用平台提供代码出错
用平台提供代码在PAI跑cifar10报错,代码没做改动
Tensorflow text_generation
我正在处理代码https://www.tensorflow.org/tutorials/sequences/text_generation
当我到达该行时,会产生以下错误。
sampled_indices = tf.random.categorical(example_batch_predictions[0], num_samples=1) sampled_indices = tf.squeeze(sampled_indices,axis=-1).numpy()错误
AttributeErrorTraceback (most recent call last)在
----> 1 sampled_indices = tf.random.categorical(example_batch_predictions[0], num_samples=1)2 sampled_indices = tf.squeeze(sampled_indices,axis=-1).numpy()
AttributeError: module 'tensorflow._api.v1.random' has no attribute 'categorical'系统信息 - TensorFlow版本:1.12 Uupntu上的Jupyter NoteBooks
昀龙-Tensorflow框架实战
云栖大讲堂-编程语言专场
https://yq.aliyun.com/download/2481?spm=a2c4e.11154804.0.0.92e96a79rwMavw
我pandas明明都装好了,为什么我导入还是报错
?报错
我pandas明明都装好了,为什么我导入还是报错,重装也不行,pip安装或者下载安装的都不行。有没有遇到同样问题的兄弟,教下我 Traceback (most recent call last): File "E:/Deep Learning Data/TensorFlow Learn 1/testItemAccuracy.py", line 3, in import pandas as pd File "D:\Anaconda3\envs\tensorflow\lib\site-packages\pandas__init__.py", line 55, in from pandas.core.api import ( File "D:\Anaconda3\envs\tensorflow\lib\site-packages\pandas\core\api.py", line 5, in from pandas.core.arrays.integer import ( File "D:\Anaconda3\envs\tensorflow\lib\site-packages\pandas\core\arrays__init__.py", line 7, in from .categorical import Categorical # noqa: F401 File "D:\Anaconda3\envs\tensorflow\lib\site-packages\pandas\core\arrays\categorical.py", line 54, in from pandas.core.base import NoNewAttributesMixin, PandasObject, shared_docs File "D:\Anaconda3\envs\tensorflow\lib\site-packages\pandas\core\base.py", line 36, in import pandas.core.nanops as nanops File "D:\Anaconda3\envs\tensorflow\lib\site-packages\pandas\core\nanops.py", line 38, in bn = import_optional_dependency("bottleneck", raise_on_missing=False, on_version="warn") File "D:\Anaconda3\envs\tensorflow\lib\site-packages\pandas\compat_optional.py", line 99, in import_optional_dependency version = _get_version(module) File "D:\Anaconda3\envs\tensorflow\lib\site-packages\pandas\compat_optional.py", line 48, in get_version raise ImportError("Can't determine version for {}".format(module.name)) ImportError: Can't determine version for bottleneck
使用Tensorflow 2.0模型子类访问层的输入/输出
在一个大学练习中,我使用了TF2.0的模型子类化API。这是我的代码(它是Alexnet架构,如果你想知道……):
class MyModel(Model):
def __init__(self):
super(MyModel, self).__init__()
# OPS
self.relu = Activation('relu', name='ReLU')
self.maxpool = MaxPooling2D(pool_size=(3, 3), strides=(2, 2), padding='valid', name='MaxPool')
self.softmax = Activation('softmax', name='Softmax')
# Conv layers
self.conv1 = Conv2D(filters=96, input_shape=(224, 224, 3), kernel_size=(11, 11), strides=(4, 4), padding='same',
name='conv1')
self.conv2a = Conv2D(filters=128, kernel_size=(5, 5), strides=(1, 1), padding='same', name='conv2a')
self.conv2b = Conv2D(filters=128, kernel_size=(5, 5), strides=(1, 1), padding='same', name='conv2b')
self.conv3 = Conv2D(filters=384, kernel_size=(3, 3), strides=(1, 1), padding='same', name='conv3')
self.conv4a = Conv2D(filters=192, kernel_size=(3, 3), strides=(1, 1), padding='same', name='conv4a')
self.conv4b = Conv2D(filters=192, kernel_size=(3, 3), strides=(1, 1), padding='same', name='conv4b')
self.conv5a = Conv2D(filters=128, kernel_size=(3, 3), strides=(1, 1), padding='same', name='conv5a')
self.conv5b = Conv2D(filters=128, kernel_size=(3, 3), strides=(1, 1), padding='same', name='conv5b')
# Fully-connected layers
self.flatten = Flatten()
self.dense1 = Dense(4096, input_shape=(100,), name='FC_4096_1')
self.dense2 = Dense(4096, name='FC_4096_2')
self.dense3 = Dense(1000, name='FC_1000')
# Network definition
def call(self, x, **kwargs):
x = self.conv1(x)
x = self.relu(x)
x = tf.nn.local_response_normalization(x, depth_radius=2, alpha=2e-05, beta=0.75, bias=1.0)
x = self.maxpool(x)
x = tf.concat((self.conv2a(x[:, :, :, :48]), self.conv2b(x[:, :, :, 48:])), 3)
x = self.relu(x)
x = tf.nn.local_response_normalization(x, depth_radius=2, alpha=2e-05, beta=0.75, bias=1.0)
x = self.maxpool(x)
x = self.conv3(x)
x = self.relu(x)
x = tf.concat((self.conv4a(x[:, :, :, :192]), self.conv4b(x[:, :, :, 192:])), 3)
x = self.relu(x)
x = tf.concat((self.conv5a(x[:, :, :, :192]), self.conv5b(x[:, :, :, 192:])), 3)
x = self.relu(x)
x = self.maxpool(x)
x = self.flatten(x)
x = self.dense1(x)
x = self.relu(x)
x = self.dense2(x)
x = self.relu(x)
x = self.dense3(x)
return self.softmax(x)
我的目标是访问一个任意层的输出(为了最大化一个特定神经元的激活,如果你必须确切地知道:))。问题是,试图访问任何层的输出,我得到一个属性错误。例如:
model = MyModel()
print(model.get_layer('conv1').output)
# => AttributeError: Layer conv1 has no inbound nodes.
我在SO中发现了一些关于这个错误的问题,他们都声称我必须在第一层定义输入形状,但是正如你所看到的,它已经完成了(参见self的定义)。conv1在_init__功能)! 我发现如果我定义一个keras。layers。输入对象,我确实设法获得了conv1的输出,但试图访问更深层次的失败,例如:
model = MyModel()
I = tf.keras.Input(shape=(224, 224, 3))
model(I)
print(model.get_layer('conv1').output)
# prints Tensor("my_model/conv1/Identity:0", shape=(None, 56, 56, 96), dtype=float32)
print(model.get_layer('FC_1000').output)
# => AttributeError: Layer FC_1000 has no inbound nodes.
我在谷歌上搜索了我遇到的每一个例外,但是没有找到答案。在这种情况下,我如何访问任何层的输入/输出(或者输入/输出_shape属性)? 问题来源StackOverflow 地址:/questions/59383356/accessing-layers-input-output-using-tensorflow-2-0-model-sub-classing
TensorFlow的计算图究竟是什么呀?
TensorFlow的计算图究竟是什么呀?
Chatbot:使用在Slack中部署的Python框架的生成模型
有人可以告诉我是否可以使用tensorflow之类的python ML框架开发聊天机器人,并使用Slack的应用程序在Slack中进行部署?
据我所读,我们可以使用node.js开发一些基于检索的模型。但是我正在寻找一种生成模型。
任何能帮助我入门的东西都非常感谢。
谢谢!
关于TensorFlow官方的法英翻译demo的运行问题
demo的源地址:https://github.com/tensorflow/models/tree/master/tutorials/rnn/translate尝试了很多次都无法成功运行 报的错是希望能出一篇相关的教程 感觉机器翻译在本地上和在平台上差距挺大的 多谢了
小白PythonPandasTensorflow实现
0. 结果
F1:1.65 Accuracy: 0.01
代码请见github:github.com/jady3356/MachineLearning/tree/master/Tianchi/fresh_offline
(注:几乎每行都有注释,但是不能直接跑,注释掉了很多特征提取的代码)
这样的结果几乎可以用excel过滤来得到,由于我是ML,数据挖掘,python都是业余小白,仅仅是做练习用,请轻拍~
1. 动机
看了Ng老师的视频,做了练习拿了证书,看了看Tensorflow的基础,玩了玩阿里的PI,也拿别人的代码跑了一些预测。总感觉没有属于自己的入手的实际的toy project。突然看到有个天池大赛,里面有新人离线赛。感觉可以练练手。
2. 初探
第一感觉挺简单的,这种推荐系统都是ML人不屑于搞的东东,推荐算法也算是ML的一个应用奇葩吧。但是,我拿到这个题目的时候根本没想清楚是解决一个什么问题,应该如何建模,只知道应该是一个逻辑回归的问题。然后一股脑的把user_id, item_id, geo_hash, time, item_cat,都作为特征,把behaviro_type作为label. 当然还花了大力气把time和geo_hash数字化,做到最后却不知道怎么预测。。。渐渐发现自己根本没有入门,要学的东西太多了。如何处理csv, 如何做特征工程,倒是是要解决什么问题,怎么建立模型...统统都是小白。
3. 入门
(1) Pandas
pd貌似是ML特征处理比较流行的工具,看到大师貌似都用spark, sql. 完全不懂, 感觉pd比较容易上手。主要用到的功能有,读写csv, 数据类型转换,去重, 统计,过滤,groupby, merge, join...要提前的特征并不复杂,但是基本上要用到pd常用的功能。我没有专门去学习每一个方法,都是每要实现一点就去百度,很多方法用的很多遍都还是不理解。不过最后各个问题都有解决办法了。过程是艰难的,曾经几度想放弃。
(2)模型构建
刚开始,自己一直想不明白怎么建模。百度了一圈,主要参考三个大神的帖子:
oilbeater.com/%E9%98%BF%E9%87%8C%E5%A4%A7%E6%95%B0%E6%8D%AE%E6%AF%94%E8%B5%9B/2014/04/04/the-bigdata-race-3.html
blog.csdn.net/wy250229163/article/details/53046006
blog.csdn.net/Snoopy_Yuan/article/details/75105724
首先,用1216-1217的特征和1218是否购买(label)构成了一个训练模型。然后把1217-1218的相同的特征代入训练好的模型(各种feature的weight)来预测1219是否购买。一种简单的建模就是:
index features label
user_id, item_id feature 1/0
index可以理解为总的输入数据的index, 类似与图像识别的每张图片的index, 不能算作特征。
feature就是购买行为,时间与user_id, item_id之前的对应的数据中提取出来的列。简单理解就是通过大量的用户-商品与特征的关系的模型。
比如,用户在1216和1217点击了且加了购物车,那么1218购买的概率就很大。表现在逻辑回归的角度来看就是点击和加购物车的weight就会很大,其他收藏,购买的weight很小,甚至为负的,因为买过的人就很可能不会再买了。
4. 总结
(1) 特征还可以扩充到100维,成绩应该还可以提高,有时间再研究;
(2) 特征工程占80%的工作量一点都不假;
(3) 最后提交结果一直是0,百度了一下用notepad++打开对比了样列,发现user_id和item_id保存成了float, 弄了好几天还以为是模型或者格式不对,超囧~
(4) 大神貌似都用spark+sklearn,有空应该再学习。
(5)tensorflow建的模型或者参数初始化有点问题,貌似有梯度消失的问题,训练到30次左右,accuracy就不变了,而且不稳定,有时候很差;