_strategy.py

'''
Created on 2014-10-21


@author: XSD


# strategy #
NOTE:Encoding=UTF-8


'''
#数值类型不同
print(1 == 1.00)
print('a' == 'a ')#比较两个字符串分片所涵盖的内容
print('a' == 'a')


print('# 序列包含的值和顺序相等 | 字典是key和value #')


m = 'ABCDEF'
n = 'ABCABC'
print(m[:-4] == n[3:-1])#string截取


print('# compare #')


print('a' > 'Z')#string比较大小
print('a'.upper() == 'A')
print('AB'.lower())


print("not:", not True)#not 小写 [True | False]
print("not:", not 0)
print("not:", not 'a')


print('# block #')
if 'a' < 'Z':
    print('a < Z')
elif False or 1:
    print('True')
else:
    print('no')


#异常
goods = {'milk':21.0, 'apple':5, 'biscuit':6.3, 'coffee':3.4, 'bread':8.6}
for item in goods.values():
    print(goods.keys())
    try:
        if goods['apple'] > 10:
            print('ham:', goods['ham'])
    except (KeyError)  as error:
        print("This is no", error)
        break
    except (TypeError):
        pass
    else:print("no exception")




#迭代
w = 1
while w <= 5:
    #if w == 5:break
    print('w:%d' % w)
    w += 1
else:
    print('# over')#done: 非break结束迭代后执行


for obj in ('a', 'b', 'c', 'd'):
    if obj == 'c' or obj == 'a':
        continue
    print('obj:', obj)
    
    
while True:
    num = int(input("input a number:"))
    if num == 0:
        print('a error number!')
        break
    for num in range(num, 1, -1):
        if num == 4:break
        print('n>', num)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Traceback (most recent call last): File "D:\tensorflow2-book\data\cat-dog\diaoqu.py", line 41, in <module> pre=model.predict(nim) ^^^^^^^^^^^^^^^^^^ File "C:\Users\17732\AppData\Local\Programs\Python\Python311\Lib\site-packages\keras\utils\traceback_utils.py", line 70, in error_handler raise e.with_traceback(filtered_tb) from None File "C:\Users\17732\AppData\Local\Temp\__autograph_generated_filevg4phta4.py", line 15, in tf__predict_function retval_ = ag__.converted_call(ag__.ld(step_function), (ag__.ld(self), ag__.ld(iterator)), None, fscope) ^^^^^ ValueError: in user code: File "C:\Users\17732\AppData\Local\Programs\Python\Python311\Lib\site-packages\keras\engine\training.py", line 2169, in predict_function * return step_function(self, iterator) File "C:\Users\17732\AppData\Local\Programs\Python\Python311\Lib\site-packages\keras\engine\training.py", line 2155, in step_function ** outputs = model.distribute_strategy.run(run_step, args=(data,)) File "C:\Users\17732\AppData\Local\Programs\Python\Python311\Lib\site-packages\keras\engine\training.py", line 2143, in run_step ** outputs = model.predict_step(data) File "C:\Users\17732\AppData\Local\Programs\Python\Python311\Lib\site-packages\keras\engine\training.py", line 2111, in predict_step return self(x, training=False) File "C:\Users\17732\AppData\Local\Programs\Python\Python311\Lib\site-packages\keras\utils\traceback_utils.py", line 70, in error_handler raise e.with_traceback(filtered_tb) from None File "C:\Users\17732\AppData\Local\Programs\Python\Python311\Lib\site-packages\keras\engine\input_spec.py", line 298, in assert_input_compatibility raise ValueError( ValueError: Input 0 of layer "sequential" is incompatible with the layer: expected shape=(None, 128, 128, 3), found shape=(32, 128, 3)
07-11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值