Code Monkey home page Code Monkey logo

Comments (2)

zoooo0820 avatar zoooo0820 commented on July 28, 2024

应该是python3和python2有些区别吧,用python3的话map完事了前面还要再加个类型转换。

from pfld.

guoqiangqi avatar guoqiangqi commented on July 28, 2024

attributes_w_n= tf.to_float(attributes[:,1:6])
_num = attributes_w_n.shape[0]
mat_ratio = tf.reduce_mean(attributes_w_n,axis=0)
#TODO when use function tf.map_fn get error results [inf,nan]

mat_ratio = tf.map_fn(lambda x:1.0/x if not x==0.0 else 0.0,mat_ratio)

mat_ratio = map(lambda x: 1.0 / x if not x == 0.0 else float(images.shape[0]),sess.run(mat_ratio))
attributes_w_n = attributes_w_n * mat_ratio

你好,我在训练的时候,报错:
Expected float32, got <map object at 0x7f3936ddd6a0> of type 'map' instead.
定位问题,在“attributes_w_n = attributes_w_n * mat_ratio” 这段代码,attributes_w_n 是一个Tensor类型,而mat_ratio是一个map的地址指向,这两个明显属于不同类型,请问您是如何调试这个地方的问题的?
补充:我使用的Tensorflow 1.10.0,是我这个版本不支持这个运算吗?

python2中map返回 list 类型,python3中返回 map object 类型 ,你可以使用 list(map())强转一下

from pfld.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.