我有一个名为import tensorflow as tf
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense,Dropout,Activation,Flatten, Conv2D, MaxPooling2D
import pickle
import keras as ks
x1 =pickle.load(open("dX.pickle","rb"))
y2 =pickle.load(open("dY.pickle","rb"))
nx = x1/255.0
model = Sequential()
model.add(Conv2D(64,(3,3),input_shape = nx.shape[1:]))
model.add(Activation("relu"))
model.add(MaxPooling2D(pool_size=(2,2)))
model.add(Conv2D(64,3,3))
model.add(Activation("relu"))
model.add(MaxPooling2D(pool_size = (2,2)))
model.add(Flatten())
model.add(Dense(64))
model.add(Dense(1))
model.add(Activation('sigmoid'))
model.compile(loss = "binary_crossentropy", optimizer ="adam", metrics = ['accuracy'])
model.fit((nx,y2), batch_size = 20, validation_split =0.1,epochs=1)
img = image.load_img(r'img.png', target_size=(224,224))
prediction = model.prediction(img)
print(prediction)
的表,该表有2列:tensorflow.python.framework.errors_impl.InvalidArgumentError:
You must feed a value for placeholder tensor 'activation_2_target' with dtype float and shape [?,?]
[[{{node activation_2_target}}]]
。 test
列可以包含这样的数据
(id int, md jsonb)
现在我想将md
的所有实例更新为{
"a": {
...
"author": "alice"
...
},
"b": {
...
"author": "alice"
...
}
}
。
通过这样做,我得到了包含alice
的行的ID
bob
是否有Postgres工具来更新每个包含alice
字段的内部对象?
任何建议都值得赞赏。
答案 0 :(得分:1)
我同意@a_horse_with_no_name,最好查看您的存储空间。但是作为执行程序很有趣。我认为唯一的方法是使用jsonb_each
扩展json,使用jsonb_set
更新数据,然后使用jsonb_object_agg
将数据聚合回去:
update test as t set
md = (
select
jsonb_object_agg(
d.key,
case
when d.value->>'author' = 'alice' then
jsonb_set(d.value, '{author}', '"bob"')
else
d.value
end
)
from lateral jsonb_each(t.md) as d
)
where
exists (select * from jsonb_each(t.md) as d where d.value->>'author' = 'alice')