首页 > 其他分享 >AttributeError: 'NoneType' object has no attribute 'dtype'

AttributeError: 'NoneType' object has no attribute 'dtype'

时间:2023-10-08 09:13:13浏览次数:41  
标签:training target weight no attribute self object steps validation

 

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/tmp/ipykernel_23207/4182898696.py in <module>
     45                                                  monitor='loss')  # 由于 
     46 
---> 47 history = model.fit(x_train, y_train, batch_size=32, epochs=100, callbacks=[cp_callback])
     48 
     49 model.summary()

/home/software/anaconda3/envs/tf115/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/training.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_freq, max_queue_size, workers, use_multiprocessing, **kwargs)
    725         max_queue_size=max_queue_size,
    726         workers=workers,
--> 727         use_multiprocessing=use_multiprocessing)
    728 
    729   def evaluate(self,

/home/software/anaconda3/envs/tf115/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/training_arrays.py in fit(self, model, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_freq, **kwargs)
    641         steps=steps_per_epoch,
    642         validation_split=validation_split,
--> 643         shuffle=shuffle)
    644 
    645     if validation_data:

/home/software/anaconda3/envs/tf115/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/training.py in _standardize_user_data(self, x, y, sample_weight, class_weight, batch_size, check_steps, steps_name, steps, validation_split, shuffle, extract_tensors_from_dataset)
   2430     is_compile_called = False
   2431     if not self._is_compiled and self.optimizer:
-> 2432       self._compile_from_inputs(all_inputs, y_input, x, y)
   2433       is_compile_called = True
   2434 

/home/software/anaconda3/envs/tf115/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/training.py in _compile_from_inputs(self, all_inputs, target, orig_inputs, orig_target)
   2665         sample_weight_mode=self.sample_weight_mode,
   2666         run_eagerly=self.run_eagerly,
-> 2667         experimental_run_tf_function=self._experimental_run_tf_function)
   2668 
   2669   # TODO(omalleyt): Consider changing to a more descriptive function name.

/home/software/anaconda3/envs/tf115/lib/python3.7/site-packages/tensorflow_core/python/training/tracking/base.py in _method_wrapper(self, *args, **kwargs)
    455     self._self_setattr_tracking = False  # pylint: disable=protected-access
    456     try:
--> 457       result = method(self, *args, **kwargs)
    458     finally:
    459       self._self_setattr_tracking = previous_value  # pylint: disable=protected-access

/home/software/anaconda3/envs/tf115/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/training.py in compile(self, optimizer, loss, metrics, loss_weights, sample_weight_mode, weighted_metrics, target_tensors, distribute, **kwargs)
    341                           self.loss_functions, target_tensors):
    342       endpoint = _TrainingEndpoint(o, n, l)
--> 343       endpoint.create_training_target(t, run_eagerly=self.run_eagerly)
    344       self._training_endpoints.append(endpoint)
    345 

/home/software/anaconda3/envs/tf115/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/training.py in create_training_target(self, target, run_eagerly)
   3060       if target is None:
   3061         target_dtype = losses.LABEL_DTYPES_FOR_LOSSES.get(
-> 3062             self.loss_fn, K.dtype(self.output))
   3063 
   3064         target = K.placeholder(

/home/software/anaconda3/envs/tf115/lib/python3.7/site-packages/tensorflow_core/python/keras/backend.py in dtype(x)
   1241   ```
   1242   """
-> 1243   return x.dtype.base_dtype.name
   1244 
   1245 

AttributeError: 'NoneType' object has no attribute 'dtype'
AttributeError:“ NoneType”对象没有属性“ dtype”
 可能是Numpy和TensorFlow兼容性问题。  目前使用的是TensorFlow2.1版本,于是将Numpy版本修改为1.18.5,发现问题得到解决  

 

标签:training,target,weight,no,attribute,self,object,steps,validation
From: https://www.cnblogs.com/emanlee/p/17125187.html

相关文章

  • P1003 [NOIP2011 提高组] 铺地毯
    第一思路:开一个N*N的数组,每次都扫一遍地毯范围并标记编号然后你会发现:喜提MLE为什么呢?我们来看看数据范围0≤n≤1e4n的范围是1e4,数组总大小为1e16,大约需要4000TB的内存空间服务器也不带这么玩的正解:将地毯信息用结构体存储structnode{ intx1,y1,x2,y2;//x1......
  • 2023NOIP A层联测5
    A.T1(cook)复合题,考场上只做出来了分块的部分,没有想到那个组合数求和可以用莫队分块部分具体不说了,对散块部分加权时,可以采用归并优化时间复杂度(因为我北卡长哩,卡到了晚饭之后,卡了一下午,好欸!)现在考虑问题\(\sum_{i=0}^{k}\dbinom{x}{i}\)令$(S(n,m)=\sum_{i=0}^{m}C......
  • 洛谷 P1969 [NOIP2013 提高组] 积木大赛 - 小思维
    洛谷P1969[NOIP2013提高组]积木大赛[NOIP2013提高组]积木大赛题目描述春春幼儿园举办了一年一度的“积木大赛”。今年比赛的内容是搭建一座宽度为\(n\)的大厦,大厦可以看成由\(n\)块宽度为\(1\)的积木组成,第\(i\)块积木的最终高度需要是\(h_i\)。在搭建开始之前......
  • 2023NOIP A层联测6
    A.万花筒考虑发现每次相当于把x和x+d连边,不难发现最后一定是一些环证明可以看白简B.冒泡排序趟数期望写一下我曾经比较疑惑的点为什么inv和p一定一一对应,因为我们发现只要给出我们一个inv我们就可以倒推出唯一确定的p,所以它们是一一对应的关系这道......
  • P3953 [NOIP2017 提高组] 逛公园
    Description策策同学特别喜欢逛公园。公园可以看成一张\(N\)个点\(M\)条边构成的有向图,且没有自环和重边。其中\(1\)号点是公园的入口,\(N\)号点是公园的出口,每条边有一个非负权值,代表策策经过这条边所要花的时间。策策每天都会去逛公园,他总是从\(1\)号点进去,从\(N\)......
  • LY1371 [ 20231007 NOIP 模拟赛 T0 ] 十一之争
    题意给定一个长度为\(n\)的数字串\(s\)和只包含yo的字符串\(t\),yoimiya会和oimiya玩\(n\)轮游戏,初始有一个数字串\(x\)为\(0\),每次:如果\(t_i\)是y则是yoimiya操作,如果是o则是oimiya操作。每次操作:将\(s_i\)或者\(0\)加入\(x\)的末尾。如果最......
  • BL124CN:高效稳定地实现CANOPEN和Ethernet/IP协议间的无缝转换
    BL124CN是一款功能强大的转换器,它能够将CANOPEN、JAE1939和DeviceNet等协议转换为Ethernet/IP上行协议,为用户提供了更加便捷和灵活的网络连接方式。针对下行协议(CANOPEN、JAE1939和DeviceNet),BL124CN能够实现实时的数据转换和传输。CANOPEN是一种用于控制和通讯领域的通信协议,广......
  • Ynoi2012 NOIP2016 人生巅峰
    Day\(\text{XXX}\)。注意到修改是易于复合的立方操作,而且值域非常小,所以可以直接\(O(v\logm)\)预处理出对每个\(i\in[0,v)\)操作了\(2^{j}\lem\)次的结果,维护出每一位被修改了多少次,查询某一位的值直接倍增\(O(\logm)\)即可。然后这个限制很弱,因为如果区间内有重复......
  • [ARC136E] Non-coprime DAG
    [ARC136E]Non-coprimeDAG显然只和可达性有关。注意到这样一件事情:所有偶数都是可达的。而对于奇数而言,\((x-\operatorname{lpf}(x),x+\operatorname{lpf}(x))\)这个区间内的数和\(x\)一定不可达。定义\(x\)控制的区间为\((x-\operatorname{lpf}(x),x+\operator......
  • display:none和overflow:hidden的区别
    1、display:none当将一个元素的display属性设置为none时,该元素将不会显示在网页中,并且不会占据任何空间。也就是说,该元素会完全隐藏,其他的元素会立即占据它原来的位置。该属性适用于需要完全隐藏某个元素的场景。//html代码:完全隐藏子元素<divclass="father"><di......